APPROX_PERCENTILE() GROUP BY ...
All functions > GROUP BY > APPROX_PERCENTILE() GROUP BY ...
Returns the approximate value at the given percentile.
Syntax
APPROX_PERCENTILE(expr, percentile) [ FILTER (WHERE condition) ] [ GROUP BY feature [, feature ...] ]
Notes
- Uses approximate algorithms for efficient computation on large datasets
- Percentile must be between 0.0 and 1.0 (e.g. 0.5 for median)
- NULL values are excluded from the calculation
- Returns NULL if all values are NULL or group is empty
Examples
FeatureQL
SELECT
f1 := ZIP(ARRAY[1, 2, 3, 4, 5] AS value).TRANSFORM(SELECT APPROX_PERCENTILE(value, 0.5)).UNWRAP_ONE() -- Approximate median (0.5 quantile)
;Result
| f1 BIGINT |
|---|
| 3 |