MIN
Returns the smallest value of the expression in a group of rows.
MySQL 8.1
MIN(expr)Parameters
- expr
- Expression: a number, string or date
Return value
A value of the same type as expr; strings are compared alphabetically, NULLs are ignored, NULL for an empty set
Examples
Lowest price
MySQL 8.1
SELECT MIN(unit_price)
FROM Payments;First name alphabetically
MySQL 8.1
SELECT MIN(member_name) AS first_name_alphabetically
FROM FamilyMembers;Details
Strings are compared as text, even if they contain numbers: the MIN of '9' and '10' is '10'. The function returns only the value; to get the whole row with the minimum, use ORDER BY ... LIMIT 1 or window functions.