How to sum the values of an SQL column

0

I need to make a system that catches the three biggest donors.

My table:

donate_ID | donate_NAME | donate_AMOUNT

This donate_NAME can be repeated, and if it does, its value will add up to the others, but what should be added is donate_AMOUNT .

I could not get to that logic.

    
asked by anonymous 14.12.2017 / 17:41

1 answer

1

You can use Group By to group the values in the SQL and SUM to sum the grouped values.

SELECT donate_id, 
       donate_name, 
       Sum(donate_amount) AS donate_AMOUNT 
FROM   donate 
GROUP  BY donate_name 
ORDER  BY donate_amount DESC; 
    
14.12.2017 / 17:57