APPROX_MEDIAN

APPROX_MEDIAN calculates the median value of a distribution of values. The value found has is approximately at the 50th percentile, within some error term (0.01, by default). APPROX_MEDIAN(x) is equivalent to APPROX_PERCENTILE(0.5, x)

ParameterTypeDescription
value
decimal, double
the values to be counted
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_MEDIAN(close_value)
  FROM sales_pipeline

result:

approx_median
491.0