i have 3 tables i will write the relevant fields in them.
table 1:
Sales:
ItemID
table 2:
Stock:
ItemID,
NumOfStock, StockValue, StockValue/NumOfStock as CostPerUnit
table 3:
Temp:
ItemID, Sum(StockValue)/Sum(NumOfStock) as AvgCostPerUnit
Resident Sales // its resident from sales cause i did join with stock and sales i need to join them Group By ItemID;
I need to make field with if condition in sales table the has or CostPerUnit from stocks or AvgCostPerUnit from temp, how can i use these fields from these two tables in the sales table?
i wrote the if condition but i dont how to use these fields in sales table in the condition, i tried many things but its not working