我正在尝试做一个需要的家庭作业问题。
--5. CALCULATE THE TOTAL QUANTITY ON HAND FOR EACH INVENTORY IT IN THE INVENTORY
--TABLE-IGNORE THIER DIFFERNT SIZES AND COLORS
这是我带来的查询。我看起来不错,除了 qoh 值
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;
每行返回 3143 而不是该特定 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