Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select max sum amount
Message
De
06/09/2011 11:39:01
 
 
À
06/09/2011 11:24:46
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01522791
Message ID:
01522802
Vues:
32
>>>Hi
>>>
>>>I have
>>>
>>>
>>>
>>>select sum(amount) as [total],
>>>		member_ref,
>>>		description 
>>>from payments 
>>>where description like '%Test%' 
>>>group by member_ref,description 
>>>
>>>
>>>
>>>how can I select out only the maximum sum amount for each member_ref .
>>>
>>>Thanks
>>>
>>>Nick
>>
>>The max of the sum - translate to sql server
>>
>>
>>	select max(total), ;
>>			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 2
>>
>
>
>Thanks Gregory
>
>works like a charm
>
>Nick


Thought so
Gregory
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform