average()
Calculate the average from a one-dimensional statistical aggregate
Since 1.3.0
Calculate a simple average (or mean) from the values in a statistical aggregate.
Samples
Section titled “Samples”Calculate the average of the integers from 0 to 100:
SELECT average(stats_agg(data)) FROM generate_series(0, 100) data;average-----------50Arguments
Section titled “Arguments”The syntax is:
average( summary StatsSummary1D) RETURNS DOUBLE PRECISION| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| summary | StatsSummary1D | - | ✔ | The statistical aggregate produced by a stats_agg call |
Returns
Section titled “Returns”| Column | Type | Description |
|---|---|---|
| average | DOUBLE PRECISION | The average of the values in the statistical aggregate |