SQL MIN and MAX
Return the smallest and largest value.
Syntax
MIN(expression) MAX(expression)
Work on numbers, text (alphabetical) and ISO dates.
Example
Query (on the shop database used in the SQL course)
SELECT MIN(order_date) AS first_order, MAX(order_date) AS last_order FROM orders;
Result
| first_order | last_order |
|---|---|
| 2025-01-08 | 2025-12-21 |
1 row
Related
Learn it step by step in the free lesson Summarising Data, with exercises that check your queries.