Reputation: 922
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
Upvotes: 1
Views: 1527
Reputation: 758
Should just be SELECT SUM(number) FROM table.
http://www.tizag.com/mysqlTutorial/mysqlsum.php has a nifty tutorial
Upvotes: 1
Reputation: 360652
select sum(number)
from yourtable
You'll want to look at MySQL's aggregate functions to see what all's available.
Upvotes: 0
Reputation: 16708
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. :)
Upvotes: 7