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
    -- Median over one group
    f1 := ZIP(ARRAY(1, 1, 1) AS g, ARRAY(1e0, 2e0, 9e0) AS x).TRANSFORM(
        SELECT MEDIAN(x) GROUP BY g
    ).UNWRAP_ONE()
;
Result
f1 VARCHAR
2.0

Last update at: 2026/06/20 10:08:10