Custom Search
Showing posts with label The SQL SUM Function Statement. Show all posts
Showing posts with label The SQL SUM Function Statement. Show all posts

Saturday, August 23, 2008

SQL SUM Function

The SUM function returns the total sum of a column in a given selection. NULL values are not included in the calculation.
Syntax

SELECT SUM(column) FROM table

Example

This example returns the sum of all ages in the "person" table:

SELECT SUM(Age) FROM Persons

Result:

98

Example

This example returns the sum of ages for persons that are more than 20 years old:

SELECT SUM(Age) FROM Persons WHERE Age>20

Result:

79