SQLPathLab
Aggregation · Basic

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

Table:orders
orders
amount
1200
900
1500
700

Run result

result
min_amount
700

Common issues

Are COUNT(*) and COUNT(column) the same?

No. COUNT(*) counts rows, while COUNT(column) ignores rows where that column is NULL.

Do MAX and MIN return the rest of the source row?

No. They return aggregate values only; use a join, ordering, or a window function when you need the complete row.

Where should filters go around aggregation?

Put source-row predicates in WHERE and aggregate-result predicates in HAVING.

Tags

Aggregation

Was this explanation clear?