I’m trying to do a homework problem that requires.
--5. CALCULATE THE TOTAL QUANTITY ON HAND FOR EACH INVENTORY IT IN THE INVENTORY
--TABLE-IGNORE THIER DIFFERNT SIZES AND COLORS
This is the query I’ve come with. I looks right except for the qoh value
SELECT DISTINCT(item.item_id),item.item_desc,
(SELECT SUM(inv_qoh) FROM INVENTORY WHERE i.item_id = item.item_id)
FROM ITEM item INNER JOIN INVENTORY i ON i.item_id = item.item_id;
Each rows returns 3143 instead of the value for that specific item_id.
5 Children's Beachcomber Sandals 3143
7 Girl's Soccer Tee 3143
4 Women's Fleece Pullover 3143
6 Boy's Surf Shorts 3143
1 Men's Expedition Parka 3143
3 Women's Hiking Shorts 3143
2 3-Season Tent 3143
It seems like you want to use something like this. It applies the
sum()aggregate and aGROUP BYto the remaining two fields in yourSELECTlist: