APPROX_PERCENTILE

APPROX_PRECENTILE calculates the value at a given percentile of a distribution of values. The value found has percentile approximately equal to the given percentile, within some error term (0.01, by default).

ParameterTypeDescription
value
decimal, double
the values to be counted
percentile
decimal, double
the percentile of the distribution to be found. Must be between 0.0 and 1.0, and must be the same for all values
error
decimal, double
the maximum allowable error of the percentile to be found. Must be greater than 0.0 and less than 1.0, and must be the same for all values. This argument is optional, with default value 0.01
Returns: decimal

Example

query:

SELECT APPROX_PERCENTILE(close_value, 0.75)
  FROM sales_pipeline

result:

approx_percentile
3281.0