QUANTILE_DISC() GROUP BY ...
All functions > GROUP BY > QUANTILE_DISC() GROUP BY ...
Returns an element from the group at the given discrete quantile; result type matches the aggregated expression.
Syntax
QUANTILE_DISC(expr, quantile) [ 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
- quantile uses DOUBLE (for example 0.5e0); discrete quantiles pick an actual value from the multiset
Examples
FeatureQL
SELECT
f1 := ZIP(ARRAY[1, 1, 1] AS g, ARRAY[1e0, 2e0, 3e0] AS x).TRANSFORM(SELECT QUANTILE_DISC(x, 0.5e0) GROUP BY g).UNWRAP_ONE() -- Discrete 0.5 quantile over one group
;Result
| f1 VARCHAR |
|---|
| 2.0 |