Categories: Percentile
APPROX_PERCENTILE
Returns an approximate percentile of a numeric column. It is faster than PERCENTILE_CONT on large datasets but may not be exact.
Syntax
APPROX_PERCENTILE(column_name numeric, percentile double) → DOUBLE
- column_name: The numeric column or expression for which to compute the approximate percentile.
- percentile: The percentile to use in the approximation. Must be a number between 0 and 1.
Examples
APPROX_PERCENTILE exampleSELECT APPROX_PERCENTILE(pop, 0.5) FROM Samples."samples.dremio.com"."zips.json"
-- 2780.17855684608
SELECT APPROX_PERCENTILE(v, 0.5) FROM (VALUES (1), (2), (3), (4), (5)) AS t(v)
-- 3.0
SELECT APPROX_PERCENTILE(v, 0.0) FROM (VALUES (1), (2), (3), (4), (5)) AS t(v)
-- 1.0
SELECT APPROX_PERCENTILE(v, 1.0) FROM (VALUES (1), (2), (3), (4), (5)) AS t(v)
-- 5.0