SQL 2000 - Sum in a Group By

JDCam
JDCam used Ask the Experts™
on
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

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Vitor MontalvãoIT Engineer
Distinguished Expert 2017
Commented:
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.
Database Administrator
Top Expert 2005
Commented:
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.

Author

Commented:
Disregard.... just a silly typo i didnt notice

Author

Commented:
thanks for looking... I will share the points
Brian CroweDatabase Administrator
Top Expert 2005

Commented:
Points are always appreciated but it would also be acceptable to request that the question just be deleted.

Glad you got it solved

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial