MIN
finding the minimum value.
Overview
MIN returns the smallest non-NULL input and is commonly used for lowest amounts, earliest dates, or per-group starting points. Like MAX, it does not automatically return other columns from the row containing that value. Text results depend on collation, while dates should use a real date type to avoid surprising string ordering.
Basic syntax
SELECT MIN(amount) AS min_amount FROM orders;
Examples
MIN example
Read the smallest orders.amount value and confirm that the sample minimum is 700.
Sample table
orders| amount |
|---|
| 1200 |
| 900 |
| 1500 |
| 700 |
Run result
| min_amount |
|---|
| 700 |
Common issues
No. COUNT(*) counts rows, while COUNT(column) ignores rows where that column is NULL.
No. They return aggregate values only; use a join, ordering, or a window function when you need the complete row.
Put source-row predicates in WHERE and aggregate-result predicates in HAVING.
Tags
Was this explanation clear?
Thanks. This feedback will inform the next content review.