MIN and MAX
Return the smallest or largest value in a column. They work on numbers, dates and text.
Syntax
MIN(column)MAX(column)
- Both ignore NULL values.
Example
SELECT MIN(unit_price) AS cheapest, MAX(unit_price) AS priciest FROM products;
The cheapest and most expensive unit price: 2.10 and 4.50.
Tables used: products. Try it in a lesson below.
Common mistakes
- MIN and MAX on text compare alphabetically, and dates compare by time.