I've been trying to use Sum() with GROUP BY but I get errors regarding the other fields that I'm not summing or grouping.
SELECT [ID]
,[SystemNum]
,[PurchaseDescription]
,[ModelNumber]
,[Brand]
,[Quantity]
,[Cost]
,Quantity*Cost AS 'Amount'
,SUM(Quantity*Cost) AS 'Total'
FROM [Equipment].[dbo].[SystemsComponents]
GROUP BY
[SystemNum]
Msg 8120, Level 16, State 1, Line 2
Column 'Equipment.dbo.SystemsComponents.ID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
why767
No comments:
Post a Comment