SQL MAX and MIN Functions
The SQL MAX() and MIN() functions allow you to display maximum and minimum values in a set.
MAX ([DISTINCT]|[ALL] <expression>) MIN([DISTINCT]|[ALL] <expression>)
Here we have employee table
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
To find the highest and lowest salary of employees on the lot, the following query could be used:
SELECT MAX(salary) max_salary, MIN(salary) min_salary FROM employees
Here is the output:
max_salary min_salary ---------- ---------- 4700.00 2000.00