MEDIAN() GROUP BY ...
All functions > GROUP BY > MEDIAN() GROUP BY ...
Returns the median of the values in the group as DOUBLE.
Syntax
MEDIAN(expr) [ FILTER (WHERE condition) ] [ GROUP BY feature [, feature ...] ]
Notes
- NULL values are ignored where the underlying aggregate skips NULLs
- Can be used with FILTER (WHERE condition) and GROUP BY like other aggregates
Examples
FeatureQL
SELECT
f1 := ZIP(ARRAY[1, 1, 1] AS g, ARRAY[1e0, 2e0, 9e0] AS x).TRANSFORM(SELECT MEDIAN(x) GROUP BY g).UNWRAP_ONE() -- Median over one group
;Result
| f1 VARCHAR |
|---|
| 2.0 |