Geeeting
im kinda new to SQL and im trying to figure out how to merge between 3 tables and use sum function aswell it's little bit complicated ! i will demonstrate this in an example :
Table SalesOrder :
SalesOrderID | OrderDate |
- 1 | 1/1/2000
- 2 | 1/1/2010
Table SalesOrderDetail
SalesOrderDetailID | salesOrderID | Product
- 1 | 1 | Car_BLue
- 2 | 2
| Car_Yellow
- 3 | 3 | Car_Blue
- 4 | 4
| Car_Yellow
ProductCost
Product | Start Date cost | End Date cost | Cost
Car_yellow | 1/1/1990 | 1/1/2005 | 100
car yellow | 1/2/2005 | NULL | 200
Blue Car | 1/1/1990 | NULL | 200
i want my select statement to be something like that the problem the cost change depend on the order date and i need to merge 2 table to get the information :
SalesOrderDetailID | salesOrderID | Product | Cost