Kristián Partl
Kristián Partl

Reputation: 21

SQL sum all values in column

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?

Upvotes: 1

Views: 1778

Answers (1)

GMB
GMB

Reputation: 222462

Just sum():

select sum(number) as total_number
from mytable

Upvotes: 5

Related Questions