Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Max sum query
Message
 
 
To
07/09/2011 06:05:15
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Miscellaneous
Thread ID:
01522804
Message ID:
01522882
Views:
30
>Thanks Naomi
>What I ended up with was
>
>
>WITH Maximumspend (MaxTotal, member_ref) AS
>(select max(total) as [MaxTotal],
>			member_ref 
>		from ( 
>			select	sum(amount) as Total, 
>					member_ref, 
>					description 
>			from payments
>				where description like '%Test%' 
>				group by member_ref, description 
>			)  X
>		group by member_ref
>)
>select Tier =  case when Maxtotal <= 10 then 'Tier1' 
>           when Maxtotal between 10 and 20 then 'Tier2' 
>           when Maxtotal > 20 then 'Tier3' END ,
>			member_ref into tempdb.dbo.temptiers from Maximumspend
>
>
>
Yes, that's what I meant.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform