I need to fix this query so that it will give me the part number, part description and on hand value for each part in the SG class. This is what I have so far. but it just gives me the total value of all the items in the SG class. How can I have it where it will give me the total based on the d开发者_如何转开发escription?
SELECT PART_NUM, DESCRIPTION, SUM(ON_HAND * PRICE) AS ON_HAND_VALUE
FROM PART
WHERE CLASS = 'SG'
PART_NUM DESCRIPTION ON_HAND_VALUE
BV06 Home Gym 48282.75
Part Table "All the items in the SG class"
PART_NUM DESCRIPTION ON_HAND CLASS WAREHOUSE PRICE
BV06 Home Gym 45 SG 2 794.95
KV29 Treadmill 9 SG 2 1390.00
How can I have it where it will give me the total based on the description?
Add the Group By clause
SELECT PART_NUM, DESCRIPTION, SUM(ON_HAND * PRICE) AS ON_HAND_VALUE
FROM PART
WHERE CLASS = 'SG'
GROUP BY DESCRIPTION
Add..
Group By Part_Num, Description
精彩评论