SQL SUM


Example

Sum function sum the value of all the rows in the group. If the group by clause is omitted then sums all the rows.

select sum(salary) TotalSalary
from employees;
TotalSalary
2500
select DepartmentId, sum(salary) TotalSalary
from employees
group by DepartmentId;
DepartmentIdTotalSalary
12000
2500