SUM using GROUP BY

  • Thread starter Thread starter ashwini.hari
  • Start date Start date
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
 
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 <--
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

SQL and MS-Access 1
Aggregate Function Error 0
DSum Problem 2
SUM in a UNION query 2
Incorrect sum in MS Access query 1
Query 2
Query Source for Text Box 7
Sum time calculation in section footer of report 1

Back
Top