BecauseGeek BecauseGeek - 5 months ago 62
SQL Question

select donater with his max donation

I have Donaters table:


And Donations table:


what I want is to get all donaters with their max donation amount like this:


I have tried the following query to get the result.

select,,max(b.donation_amount) max_d
from donaters a left join donations b on b.donater_id =
groub by,,max_d

However, it returns duplications.

Answer Source
select Dtrs.Id ,,MAX_Donations.donation_amount from  
         Donaters Dtrs left join (
Select Dtrs_id ,Max(Dons.donation_amount) donation_amount  from Donations Dons 
         inner join Donaters Dtrs on Dons.donater_id = 
Group By Max_Donations on Max_Donation.Dtrs_id =

Here for more information

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download