AggregateSQL standard

MIN

Returns the smallest value among the rows.

Syntax

MIN(<expression>)

An aggregate function: it returns the smallest value from a group of rows. It works not only with numbers but also with dates (the earliest) and text (the first alphabetically). It skips NULL. To find the largest value, use MAX.

Data for the examples

employees

namedepartmentsalarybonusphone
Emmabackend1200300+44 7700 900123
Liambackend1000NULLNULL
Oliviafrontend1350150+44 7700 900456
Noahfrontend950NULL+44 7700 900789
Sophiadesign1200200NULL

orders

idcreated_atamount
12026-07-03 10:15:00120.50
22026-07-28 18:40:0080.25
32026-08-09 09:05:00199.99
42026-08-21 14:30:0045.00
52026-09-02 11:00:0064.75

These tables already exist in the sandbox — the examples below use them. Want to try this in your own database? Copy the SQL.

The lowest salary
SELECT MIN(salary) AS lowest
FROM employees;
lowest
950
The first order
SELECT MIN(created_at) AS first_order
FROM orders;
first_order
2026-07-03 10:15:00
The lowest salary in each department
SELECT department,
MIN(salary) AS lowest
FROM employees
GROUP BY department
ORDER BY department;
departmentlowest
backend1000
design1200
frontend950

Watch out

MIN gives a value, not a row. SELECT name, MIN(salary) FROM employees is an error, because name isn't in GROUP BY. Who exactly earns the least is shown by ORDER BY salary LIMIT 1 or a subquery.

Numbers stored as text are compared as text: of '9' and '10', the smaller is '10'.

Don't confuse it with LEAST: that one compares several values within one row.

Related functions

Learn more in the course