# SUM – Return summation of selected column – Aggregate Functions

SUM function returns the summation of selected column. You can also obtain the sum excluding duplicate data using DISTINCT parameter, however, you rarely use DISTINCT parameter with SUM.

example: Return the summation of employees’ age.

SELECT SUM(age) FROM tbEmpTable; SUM(age) -------------------------- 123

example: Return the summation of employees’ age after excluding duplicate ages.

SELECT SUM(DISTINCT age) FROM tbEmpTable; SUM(DISTINCT age) -------------------------- 89

example: Return the summation of age by each gender.

SELECT gender, SUM(age) FROM tbEmpTable GROUP BY gender; gender, SUM(age) -------------------------------- male 73 female 50

Posted in Aggregate Functions