SUM

suggest change

SUM adds the non-NULL values in the group. If GROUP BY is omitted, it sums the whole table. When every value is NULL, SUM returns NULL. The salaries below are the Employees sample: 1000, 400, 600, and 500.

select sum(salary) TotalSalary
from Employees;

TotalSalary|
—— |
2500 |

select DepartmentId, sum(salary) TotalSalary
from Employees
group by DepartmentId;

Department 1 is James, John, and Johnathon (1000 + 400 + 500). Department 2 is Michael (600).

| DepartmentId | TotalSalary| | —— | — | | 1 | 1900 | | 2 | 600 |

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents