| [ Web Proxy ] |
| Viewing: https://riptutorial.com/sql/example/3254/sum | [Back] [Original] |
[logo rip]
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 |
| Web Proxy Viewer | New URL | Original Page |