← All languages
SQL keyword of the day
Random

SUM

Return the total sum of a numeric column.

Description

The SUM() aggregate function calculates the total sum of values in a numeric column. It ignores NULL values in the calculation. SUM can be used with DISTINCT to sum only unique values. It is commonly used with GROUP BY to calculate totals for each group. SUM only works with numeric data types and returns NULL if there are no matching rows.

Arguments

NameDescriptionOptional
expression A numeric column or expression to sum. No

Example

SELECT SUM(amount) FROM orders;
SELECT department, SUM(salary) FROM employees GROUP BY department;