SUM using GROUP BY

A

ashwini.hari

Following is the skeleton of a simple query I wrote,to find the sum of
values by grouping multiple columns ( from different tables
joins).Now,even if the SUM(C.column3) is NULL( verified this by
running a separate value specific query), it shows up with values from
the previous columns!

Not sure what is the problem here...Please help.

SELECT A.column1, B.column2, ISNULL(SUM(C.column3),0)
<FROM A JOIN B AND JOIN C>
GROUP BY A.column1, B.column2
 
S

Stefan Hoffmann

hi,

Following is the skeleton of a simple query I wrote,to find the sum of
values by grouping multiple columns ( from different tables
joins).Now,even if the SUM(C.column3) is NULL( verified this by
running a separate value specific query), it shows up with values from
the previous columns!

Not sure what is the problem here...Please help.

SELECT A.column1, B.column2, ISNULL(SUM(C.column3),0)
<FROM A JOIN B AND JOIN C>
GROUP BY A.column1, B.column2
What result do you expect?



mfG
--> stefan <--
 
D

Douglas J. Steele

Assuming this is not a pass-through query, try:

SELECT A.column1, B.column2, SUM(Nz(C.column3,0))
<FROM A JOIN B AND JOIN C>
GROUP BY A.column1, B.column2

The IsNull function in Access is different than the ISNULL function in SQL
Server: you seem to be using the latter. As well, you want to handle Nulls
before summing them, not after.
 
Top