SUM

From Oracle FAQ
Jump to: navigation, search

SUM is a SQL function used to get the sum of numeric column values. NULL values will be ignored. SUM(DISTINCT n) can be used to only sum unique values.

[edit] Examples

Sum of all employees' salaries:

SELECT SUM(sal) FROM emp;

Sum of salaries per department:

SELECT deptno, SUM(sal) FROM emp GROUP BY deptno;

Sum of distinct values:

SELECT SUM(DISTINCT ...

[edit] Also see