SQL 2000 - Sum in a Group By

Working on an old SQL 2000 DB.
Having problem with a simple Select. Can someone give a quick hand

There are two number (Int) columns in the select. I need to group by 3 other fields.  The number fields are being selected as SUM().
If I include the number fields in the Group By, I get too many rows as most of the values are different.
If I exclude them from the group, I get error: 'Not in aggregate function or Group by'. Why does it not recognize SUM as an aggregate?
is it the column type?

Select
Field_A,
Field_B,
Field_C,
SUM(Num_A),
SUM(Num_B)
FROM MYTABLE
Group By Field_A, Field_B, Field_C
Order By Field_A

Open in new window

LVL 1
JDCamAsked:
Who is Participating?
 
Brian CroweDatabase AdministratorCommented:
I don't see anything wrong with the query you posted if Num_A and Num_B are numeric.  Try providing an alias for the aggregate columns but otherwise I'm at a loss.
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
Can't understand the issue. The SELECT you provided should work fine.
Maybe if you post with some sample data I'll understand it better.
0
 
JDCamAuthor Commented:
Disregard.... just a silly typo i didnt notice
0
 
JDCamAuthor Commented:
thanks for looking... I will share the points
0
 
Brian CroweDatabase AdministratorCommented:
Points are always appreciated but it would also be acceptable to request that the question just be deleted.

Glad you got it solved
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.