Skip to content

approx_percentile_rank()

Estimate the percentile of a given value from a `uddsketch`

Since 1.0.0

Estimate the percentile at which a given value would be located.

Estimate the percentile rank of the value 99, given a sample containing the numbers from 0 to 100.

SELECT
approx_percentile_rank(99, uddsketch(100, 0.001, data::double precision))
FROM generate_series(0, 100) data;
approx_percentile_rank
----------------------------
0.9900990099009901

The syntax is:

approx_percentile_rank(
value DOUBLE PRECISION,
sketch UddSketch
) RETURNS DOUBLE PRECISION
NameTypeDefaultRequiredDescription
valueDOUBLE PRECISION-the value to estimate the percentile of
sketchUddSketch-the uddsketch aggregate
ColumnTypeDescription
approx_percentile_rankDOUBLE PRECISIONThe estimated percentile associated with the provided value.