SQL: MIN()
19 March 2023 (Updated 27 April 2025)
MIN() is an aggregate function that lets you find the minimum value in a set.
Syntax
MIN(expression)
Example & execution plan
select min(salary) from salaries;
SQL will execute the above query in the following steps:
- Read through the
salariestable and extract the value from thesalarycolumn for each row. - For each value in the
salarycolumn, compare it to a running minimum value. If the current value is lower than the running minimum value, update the running minimum value to the current value. - After running through all the rows, return the running minimum value as the result of
MIN().
Other notes
The data type determines the comparison algorithm
If you pass a set of INT values to MIN(), it will return the smallest number. If you pass it a set of DATE values, it will return the earliest date. And so on,.
Sources
Tagged:
SQL
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment