Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL aggregate SUM statements 1

Status
Not open for further replies.

dolodolo

Technical User
May 27, 2003
86
US
Hi,

I am trying to get rid of zero amounts on my report. I have the following code in my script:

Having SUM(
abs(sum(Case tr.upostdate When convert(datetime,'01/01/#dat1#') then d.samount else 0 End)) +
abs(sum(Case tr.upostdate When convert(datetime,'02/01/#dat1#') then d.samount else 0 End)))<> 0

When I run it I get this error:

Cannot perform an aggregate function on an expression containing an aggregate or a subquery

Any help would be much appreciated.

Thanks
 
I think you can get the same results without the first sum

Having abs(sum(Case tr.upostdate When convert(datetime,'01/01/#dat1#') then d.samount else 0 End)) +
abs(sum(Case tr.upostdate When convert(datetime,'02/01/#dat1#') then d.samount else 0 End))<> 0

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top