MAX
aggregation
What changes
- Input
- the argument expression over each group's rows (COUNT(*) reads no column)
- Output or change
- one value per group (or one for the whole input when there is no GROUP BY)
- Return type
- Returns a value same as expression.
Syntax at a glance
MAX ( [ ALL | DISTINCT ] expression )
Work example
Find the latest date or highest value inside a group.
Test ties and null-only groups before using the result as a single-row decision.
Check your work MAX returns a value, not the full row that contains it.
Practice SQL
Open in SQL FlowSELECT MAX(n) AS largest FROM (VALUES (8), (3), (5)) AS v(n);
Open Microsoft Learn for full syntax, permissions, and details for your version.