Intermediate · Lesson 3 of 20

MIN and MAX

MIN finds the smallest value. MAX finds the largest value.

Highest salary:

SELECT MAX(salary) FROM employees;

Lowest salary:

SELECT MIN(salary) FROM employees;

Both in one query:

SELECT MIN(salary) as lowest,
       MAX(salary) as highest
FROM employees;

Works with dates and text too!

Check your understanding

Find both the minimum and maximum salary.

Examples run on the employees sample database. Open any of them in the playground to experiment.

Practice it on a real question

All Aggregation questions

Practice on your iPhone

Query Dojo for iPhone has 85 interview questions, timed mock interviews and a tile builder, so you can write queries without a keyboard.

Get the app