SQL MAX and MIN Functions
The SQL SUM() function uses to sum the values. Here is the syntax:
SUM([DISTINCT]|[ALL] <numeric_expression>)
We have the sample table: Employee
employee_id name salary
----------- -------- -------
1 jack 3000.00
2 mary 2500.00
3 newcomer 2000.00
4 anna 2800.00
5 Tom 2700.00
6 foo 4700.00
In order to calculate the total amount of salary the company has to pay each month for all employees, we can use this query:
SELECT SUM(salary) AS total_salary
FROM employee
total_salary
------------
17700.00
Related Tutorials