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;

| DepartmentId | TotalSalary| | —— | — | | 1 | 2000 | |2 | 500 |