Skip to main content
Since 1.0.0 Estimate the approximate value at a percentile from a uddsketch aggregate.
approx_percentile(
  percentile DOUBLE PRECISION,
  uddsketch  UddSketch
) RETURNS DOUBLE PRECISION

Arguments

NameTypeDefaultRequiredDescription
percentileDOUBLE PRECISION-the percentile to compute. Must be within the range [0.0, 1.0]
sketchUddSketch-the uddsketch aggregate

Returns

ColumnTypeDescription
approx_percentileDOUBLE PRECISIONthe estimated value at the requested percentile

Samples

Estimate the value at the first percentile, given a sample containing the numbers from 0 to 100.
SELECT
  approx_percentile(0.01, uddsketch(data))
FROM generate_series(0, 100) data;
approx_percentile
-------------------
            0.999