I have two tables called PRODUCT and LINEITEMS and I am trying to use a combination of a JOIN and GROUP BY to display a single row for each product with the total quantity sold next to it. The structure of the tables is as follows:
- PRODUCT (partno#, description, category, unitcost, unitprice)
- LINEITEM (order#, line#, partno#, quantity, unitprice
I've got this far but the quantity displayed next to each product is the sum of all quantities from all products and not the sum of the quantity sold for that product on the line.
SELECT p.description, sum(li.quantity)
FROM product p, linetem li
GROUP BY p.description;