What do MIN() and MAX() do?
MIN() and MAX() are aggregate functions that find the minimum and maximum value in a dataset.
MIN(column)returns the smallest value in a column;MAX(column)returns the largest value.
Example
sql
SELECT MIN(salary), MAX(salary)
FROM employees;Shows the smallest and the largest salary.
You can use it with GROUP BY:
sql
SELECT department, MIN(salary), MAX(salary)
FROM employees
GROUP BY department;Shows the salary range in each department.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.