SUM(EXPR) SUM(EXPR)

3. SUM(expr)

SUM(DISTINCT expr) provides a total by adding all the unique values returned

after expr is evaluated for each row in the group. SUM(expr) and SUM(ALL expr)

provide a total by adding expr for each row in the group. Null values are ignored.

The expr parameter must be a numeric value. Consider the following queries:

Query 1: select sum(2) from employees;

Query 2: select sum(salary) from employees;

P AR T II

Query 3: select sum(distinct salary) from employees;

Query 4: select sum(commission_pct) from employees;

There are 107 rows in the EMPLOYEES table. Query 1 adds the number 2 across

107 rows and returns 214. Query 2 takes the SALARY column value for every row in

the group, which in this case is the entire table, and returns the total salary amount of