MAX() GROUP BY ...
All functions > GROUP BY > MAX() GROUP BY ...
Returns the maximum value in the group.
Syntax
MAX(expr) [ FILTER (WHERE condition) ] [ GROUP BY feature [, feature ...] ]
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
Examples
FeatureQL
SELECT
f1 := ZIP(ARRAY[1, 5, 3] AS value).TRANSFORM(SELECT MAX(value)).UNWRAP_ONE() -- Maximum in one group
;Result
| f1 BIGINT |
|---|
| 5 |