In MySQL, SUM() function is used to return the total sum of a numeric column in a table.
SUM() Syntax
SELECT SUM(column_name) FROM table_name;
We have a table "employee" as below:
employee
id first_name last_name salary
.......................................................
1 John Simp 10000
2 Chris Hely 25000
3 Joy Roy 20000
4 Jenny Mill 35000
SUM() Example
The below query gives the sum of all the "salary" column from the "employee" table:
SELECT SUM(salary) AS total_salary FROM employee;
Hope this will help you :)
0 Comment(s)