The SUM()
function is used to return the sum of the specified column that contains numeric values.
SELECT SUM(column)
FROM table
WHERE condition;
ClassID | NumberOfStudents |
1 | 25 |
2 | 20 |
3 | 15 |
CREATE DATABASE name;CREATE TABLE School (ClassID int,NumberOfStudents int);INSERT INTO SchoolVALUES (1, 25);INSERT INTO SchoolVALUES (2, 20);INSERT INTO SchoolVALUES (3, 15);SELECT *FROM School;
SELECT SUM(NumberOfStudents)FROM School;
This function finds the sum of the NumberOfStudents
numeric column.