SQL TutorialLesson 16Free preview
SQL Min()
This lesson is part of SQL · All levels
Summary
The MIN function returns the smallest value in the summed columns, both numbers and text sorted by collation. The NULL value is ignored so that MIN remains working even though there is empty data. MIN can be used without a GROUP BY for one summary value or with a GROUP BY per group.
Key points
- Returns the smallest value and ignores the first.
- Work on numbers, text, and dates.
- Can be used with GROUP BY for each group's minimum value.
- You can't use it directly in the WHERE clause; use subqueries when necessary.
- Example of minimum filter: WHERE price = (SELECT MIN(price) FROM products).
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.