Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Max sum query
Message
 
 
À
07/09/2011 06:05:15
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Divers
Thread ID:
01522804
Message ID:
01522882
Vues:
31
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform