for example Sales Table
SlNo Inventorycode Cost Date
1.    100001       1.8   01/01/2017
2.    100002       2.3   01/01/2017
3.    100002       3.5   02/01/2017
4.    100001       2.5   03/01/2017
Stock Table
SlNO InventoryCode  Cost    Date
1.    100001              01/01/2017
2.    100002              01/01/2017
3.    100001              01/01/2017
4.    100002              02/01/2017
5.    100001              01/01/2017
6.    100002              03/01/2017
from the above data, I want to update the COST of the Salestable to stocktable for the concern ItemCode and date.If no sales occurred on the concern date i want to update(StockTable) the cost of the previous date's cost.
                        
I haven't tested it but this should work
It would be nice if you could share the schema and data for quick testing