How to sum the values of an SQL column

Asked

Viewed 2,083 times

0

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

My table:

donate_ID | donate_NAME | donate_AMOUNT

This donate_NAME can be repeated, and if this happens its value will be added with the others, but what should be added is the donate_AMOUNT.

I couldn’t reach that logic.

1 answer

1


You can use the Group By to group the values in 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; 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.