Skip to content

SQL MIN Function

Syntax

The MIN function in SQL is used to find the minimum value of a column.

-- Find the minimum value in a column
SELECT MIN(column1)
FROM table_name;
-- Find the minimum value for each group
SELECT column2, MIN(column1)
FROM table_name
GROUP BY column2;

Example

-- Find the minimum salary of all employees
SELECT MIN(salary)
FROM employees;
/* Output:
| MIN(salary) |
|-------------|
| 40000 |
*/
-- Find the minimum salary for each department
SELECT department, MIN(salary)
FROM employees
GROUP BY department;
/* Output:
| department | MIN(salary) |
|-------------|-------------|
| Sales | 50000 |
| Marketing | 40000 |
| HR | 60000 |
*/