Skip to content
Advertisement

Count Most donator SQL

I wanted to know how would i count most donated number for a person and how to make list from most donator to the lowest.

Database looks like this :

Note : If anyone would guide me on how the table is made on stackoverflow, thank you.

Advertisement

Answer

The easiest is to group by the email, sum the amount to get a total, and order by descending total.

And if you want only the top 3 of those, add a LIMIT 3 at the end of the SQL.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement