mean()

  1. mean(sketch UddSketch) RETURNS DOUBLE PRECISION
  1. mean(digest tdigest) RETURNS DOUBLE PRECISION

Get the exact average of all the values in the percentile estimate. (Percentiles returned are estimates, the average is exact). This is provided in order to save space when both a mean and a percentile estimate are required as part of continuous aggregates. You can simply compute a single percentile estimator and do not need to specify a separate avg aggregate, just extract the mean from the percentile estimator.

Required arguments

NameTypeDescription
sketch / digestUddSketch/tdigestThe sketch to extract the mean value from, usually from a percentile_agg() call.

Returns

ColumnTypeDescription
meanDOUBLE PRECISIONThe average of the values in the percentile estimate.

Sample usage

  1. SELECT mean(percentile_agg(data))
  2. FROM generate_series(0, 100) data;
  1. mean
  2. ------
  3. 50