Skip to main content

What does SUM() do?

SUM() is an aggregate function that totals the values in a numeric column.

It adds up all the non-empty (NOT NULL) values and returns one total.

Example

sql
SELECT SUM(salary) FROM employees;

Returns the total of every employee's salary.

You can use it with GROUP BY to total by category:

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

Shows the salary total in each department.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.