Hi,
I am trying to add up the quantity of various items found in a table, that is controlled by a second/third joined table using the IN search criteria. However I am unable to work out getting the SUM of all the items.
The tables are as below:
Table One: RDN1
ItemCode Quantity
80-05-910 5
80-05-910 2
80-21-910 3
80-05-918 5
Table Two: MET_OBOM
DocEntry ItemCode
1 80-05-910
2 80-05-918
3 80-21-910
Table Three: MET_BOM1
DocEntry ItemCode
1 30-05-618XD
2 30-05-618XD
3 30-05-619XD
Query so far:
SELECT T0.ItemCode, T0.Quantity (SELECT SUM(T1.Quantity) FROM RDN1 T1 WHERE T0.ItemCode = T1.ItemCode )
FROM RDN1 T0
WHERE T0.ItemCode IN (SELECT T0.U_ItemCode FROM MET_OBOM T0 INNER JOIN MET_BOM1 T1 ON T0.DocEntry = T1.DocEntry WHERE T1.U_ItemCode = '30-05-618XD')
ORDER BY T0.DocEntry ASC
From the query I get:
ItemCode Quantity SUM
80-05-910 5 7
80-05-910 2 7
80-05-918 5 5
Is there any way to get SUM to include all ItemCodes return i.e. SUM = 12
Any help is much appreciated.
Kind Regards,
Matthew