Skip to content

approx_percentile()

Estimate the value at a given percentile from a `tdigest`

Since 1.0.0

Estimate the approximate value at a percentile from a tdigest aggregate.

Estimate the value at the first percentile, given a sample containing the numbers from 0 to 100.

SELECT
approx_percentile(0.01, tdigest(data))
FROM generate_series(0, 100) data;
approx_percentile
-------------------
0.999

The syntax is:

approx_percentile(
percentile DOUBLE PRECISION,
tdigest TDigest
) RETURNS DOUBLE PRECISION
NameTypeDefaultRequiredDescription
percentileDOUBLE PRECISION-The percentile to compute. Must be within the range [0.0, 1.0]
tdigestTDigest-The tdigest aggregate
ColumnTypeDescription
approx_percentileDOUBLE PRECISIONThe estimated value at the requested percentile.