1
votes

I have table with 500+ rows and I want to sum all the values in a column.

Example:

 name  | number
 ----------------
 name1 | 25
 name2 | 10
 name3 | 5
 name4 | 20

The total sum is: 60

I can do that via PHP but is this possible using an SQL query?

1
The sum() is 60, and that is a big hint.Gordon Linoff
Does this answer your question? SQL- Add up Values in a ColumnNigel Ren

1 Answers

4
votes

Just sum():

select sum(number) as total_number
from mytable