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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using sum to eliminate records

Status
Not open for further replies.

sap1958

Technical User
Oct 22, 2009
138
US
select giftid,
sum(case when gifteffdat >'7/1/2009' then giftamount else 0)end as FY11

from gifttable
where [FY11] = 0
group by giftid

I tried using FY11 = 0 and get an error message. I am trying to use the FY11 to eliminate records based on the date range. Can I do this or must I repeat the sum(case formula at the bottom after the group by

I am using SQL 2005
 


Hi,

Why are you summing a DATE? What does that mean, addin dates?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Skip he is using giftamount in the sum

As the query is shown the parenthesis is on the wrong side of the end
Code:
sum(case when gifteffdat >'7/1/2009' then giftamount else 0)end 
-- Should be
sum(case when gifteffdat >'7/1/2009' then giftamount else 0 end[b])[/b]

djj
The Lord is My Shepard (Psalm 23) - I need someone to lead me!
 
Code:
select giftid,
sum(case when gifteffdat >'7/1/2009' then giftamount else 0 end) as FY11

from gifttable

group by giftid
having sum(case when gifteffdat >'7/1/2009' then giftamount else 0 end) = 0

PluralSight Learning Library
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top