Description
The SQL Aggregate Functions can be used to perform calculations on a set of values and return a single value, based on the type of functions.
- These can be used only with a SELECT statement.
- These perform calculations on a set of values and return a single value.
See aggregate functions for more details.
Let's look at an example SELECT statement with a MAX() function, which returns the maximum value.
Table Date
employee_id | employee_name | gender | birth_date | hire_date | salary |
1 | Robin Hood | M | 1990-10-10 | 2010-10-15 | 25000 |
2 | Tony Blank | M | 1982-08-07 | 2010-01-05 | 89000 |
3 | Andrew Russel | M | 1998-05-04 | 2012-02-20 | 28000 |
4 | James Cooper | NULL | 2000-10-20 | 2015-05-10 | 45000 |
5 | Rose Cutler | F | 1985-08-08 | 2015-06-21 | 65000 |
Example
The below SELECT statement returns the maximum value of a set of values.
SELECT MAX(salary) FROM employees;
After successful execution, the output contains the below data.
MAX(salary) |
89000 |
Overall
We now understood the usage of the MAX() function on a SELECT statement.