Hi,
I have two tables, as follows:
ItemTable:This table has one record per item for each month.
Month_No,Item_no,Total_Sales
200401,0001A,22500.00
200402,0001A,36500.00
200403,0001A,23000.00
:
:
PriceTable:This table has one record per item, each month the price of the item changed. If price of the item 0001A was changed once in Jan 2004 and once in March 2004, then it will like:
Month_No,Item_No,Price
200401,0001A,$55.00
200403,0001A,$57.50
:
:
Now if want to run a report which will return the monthly sales with the latest price as of that month:
MonthNo,ItemNo,Price,Sales
200401,0001A,$55.00,22500.00
200402,0001A,$55.00,36500.00
200403,0001A,$57.50,23000.00
I know that one way to create such report is to come up with a complete join in the sql statement. But if I am allowed to change the structure of the table in order to avoid any complex join, how can i design the table, so that it always return the largest month?
Any help is appreciated,
I have two tables, as follows:
ItemTable:This table has one record per item for each month.
Month_No,Item_no,Total_Sales
200401,0001A,22500.00
200402,0001A,36500.00
200403,0001A,23000.00
:
:
PriceTable:This table has one record per item, each month the price of the item changed. If price of the item 0001A was changed once in Jan 2004 and once in March 2004, then it will like:
Month_No,Item_No,Price
200401,0001A,$55.00
200403,0001A,$57.50
:
:
Now if want to run a report which will return the monthly sales with the latest price as of that month:
MonthNo,ItemNo,Price,Sales
200401,0001A,$55.00,22500.00
200402,0001A,$55.00,36500.00
200403,0001A,$57.50,23000.00
I know that one way to create such report is to come up with a complete join in the sql statement. But if I am allowed to change the structure of the table in order to avoid any complex join, how can i design the table, so that it always return the largest month?
Any help is appreciated,