Edited by HansV to present data in tables – see Help 19
I have a table (itemsize) which contains fields productid, yearno, weekno, itemsperbox.
Entries will be made in this table giving the year (eg.2004) and week number (eg. 27). The itemsperbox is an integer.
I also have a table (sold) which contains productid, yearno, weekno, quantitysold. There is one entry for each yearno/weekno for a product storing the quantity sold this week and as integer.
I need to product a query which will look in the sold table and multiply the quantity by the appropriate itemsperbox from the itemsize table.
eg. if itemsize contains the following:
ProdID | yearno | weekno | itemsperbox |
a | 2003 | 25 | 100 |
a | 2003 | 28 | 150 |
and sold contains the following:
ProdID | yearno | weekno | sold |
a | 2003 | 24 | 50 |
a | 2003 | 25 | 20 |
a | 2003 | 26 | 30 |
a | 2003 | 27 | 15 |
a | 2003 | 28 | 20 |
a | 2003 | 29 | 25 |
then the query should give the results:
ProdID | yearno | weekno | sold | itemsperbox | total |
a | 2003 | 24 | 50 | 0 | 0 |
a | 2003 | 25 | 20 | 100 | 2000 |
a | 2003 | 26 | 30 | 100 | 3000 |
a | 2003 | 27 | 15 | 100 | 1500 |
a | 2003 | 28 | 20 | 150 | 3000 |
a | 2003 | 29 | 25 | 150 | 3750 |
I’m struggling to find a way of doing this without introducing an ending yearno/weekno in the itemsize table
If anyone can understand what I’m trying to do…….any suggestions?
John