I have 2 tables oitt and itt1. OITT is the parent table and ITT1 is the child table. I want to query the father, child, quantity of child. But in the quantity result i want to sum where childs are the same.
This is a Bill of Material table. My objective is to list all like child components and sum their quantities so I can order parts at one time.
I wrote this query but it is not summing the duplicate childs (its ok that they are duplicates because the father is different).
Select t1.father as 'Parent', t1.code as 'Child', t2.itemname as 'Description', sum (t1.quantity)
FROM ITT1 T1 INNER JOIN OITM T2 ON T1.Code = T2.ItemCode
WHERE t1.father in ('117','114')
I know I'm missing the group by but it's still not returning the expected results. Maybe I can't sum duplicate rows because t1.father is in the selection?