The SQL SUM function returns the sum of the selected column, containing numeric values.
Employees Table
employeeID | employeeName | age |
1000 | John Smith | 40 |
1001 | Fred White | 27 |
1002 | Jane Scott | 53 |
1003 | Samuel Williams | 31 |
In this example, we want to find the sum of all the employees' ages in the employees table.
Syntax
SELECT SUM(column_name)
FROM Table |
Example
SELECT SUM(age) as [Sum of Ages]
FROM employees
|
Results
The SQL SUM function is used to find the sum of the numeric values in a given column.
Did you find the page informational and useful? Share it using one of your favorite social sites.
Recommended Books & Training Resources