1
id  |  number
1   |    10
2   |    24
3   |    45
4   |    25
5   |    12

How can I get the sum of all numbers in the number column? Thanks

4 Answers 4

7
SELECT SUM(number) FROM table

Should do it.

If you only want to sum some of the numbers, or aggregate them by groups of IDs, or some other thing, then you'll need to learn about WHERE or GROUP BY clauses. :)

Sign up to request clarification or add additional context in comments.

Comments

1

Should just be SELECT SUM(number) FROM table.

http://www.tizag.com/mysqlTutorial/mysqlsum.php has a nifty tutorial

Comments

0
select sum(number)
from yourtable

You'll want to look at MySQL's aggregate functions to see what all's available.

Comments

0
SELECT SUM(number) from table ...

try the code above.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.