MAX
All functions > AGGREGATE > MAX
Returns the maximum value in the group.
Syntax
MAX(expr: T) → T
sql
Type Parameters:
T
: Any comparable type (numeric, string, date, timestamp, boolean)
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
expr | T | Yes | The expression to find the maximum value of |
num_values | ANY | No | Optional number of maximum values to return as array |
Returns
The maximum value, or array of top N values if num_values specified
Notes
- Returns the largest value in the group
- Works with numeric, string, and date types
- NULL values are excluded from the calculation
- Returns NULL if all values are NULL or group is empty
- With num_values parameter, returns an array of the N largest values
- Can be used with WHERE clause to filter before aggregation
- Can be used with GROUP BY clause for grouped aggregation