min
Calculates the minimum of the non-NULL input values. The selected value keeps its original native type.
With one argument, min is an aggregate over rows. With two or more arguments, it is a scalar function comparing the arguments of one row.
Syntax
text
min(value)
min(value1, value2, ...)Arguments
value— An expression to compare across input rows. SQL value ordering and the selected collation determine the result.value1, value2, ...— Two or more values for the scalar form.
Returned value
The smallest input value. The aggregate skips NULL and returns NULL for empty or all-NULL input. The scalar form returns NULL if any argument is NULL.
Examples
Finding the smallest salary
sql
CREATE TABLE employees (salary INTEGER);
INSERT INTO employees VALUES (46000), (NULL), (59000), (72000);sql
SELECT min(salary)
FROM employees
FORMAT csv;text
46000Comparing native dates
sql
CREATE TABLE events (day Date);
INSERT INTO events VALUES (CAST('2025-03-10' AS Date)), (CAST('2025-01-05' AS Date));sql
SELECT min(day)
FROM events
FORMAT csv;text
"2025-01-05"Comparing values within one row
sql
SELECT min(8, 3, 12), min(8, NULL, 12)
FORMAT csv;text
3,\NRelated functions
maxselects the largest value.any_valueselects a representative non-NULLvalue.min_stateandmin_mergestore and combine intermediate extrema.