SQL MIN Function
Quick summary: The SQL MIN() function returns the smallest value in a column.
SQL MIN Syntax
SELECT MIN(column_name) FROM table_name WHERE condition
SQL
SQL MIN Basic examples
SELECT MIN(price) FROM products;
SQL
Output:
Lowest product price
Finds the minimum value.
SQL MIN Real-world usage
SELECT MIN(created_at) FROM users;
SQL
Output:
First registered user date
Finds earliest timestamps.
SQL MIN Edge cases
SELECT MIN(price) FROM products WHERE category_id = 999;
SQL
Output:
NULL
Returns NULL when no rows match.
SQL MIN Common mistakes
Using MIN to get full rows
MIN returns a scalar, not a row.
Incorrect
SELECT * FROM products WHERE price = MIN(price);
Correct
SELECT * FROM products ORDER BY price ASC LIMIT 1;
Use ORDER BY + LIMIT for rows.
SQL MIN Frequently Asked Questions
What does MIN() do in SQL?
Returns the smallest value in a column.
Use case of MIN()?
Finding lowest values.
Handles NULL?
Ignores NULL values.
Return type?
Same as column type.
Common mistake?
Expecting sorted results.
Works with GROUP BY?
Yes.
Supports strings?
Yes.
Performance?
Fast with indexes.
Used in analytics?
Yes.
Alternative?
ORDER BY + LIMIT.
Handles dates?
Yes.
Best practice?
Use indexed columns.