Versions:

# average(), average_y(), and average_x() ToolkitTimescaleDB Toolkit functions are available under Timescale Community Edition. They are automatically included with Timescale Cloud. Click to learn more.

Toolkit

TimescaleDB Toolkit functions are available under Timescale Community Edition. They are automatically included with Timescale Cloud. Click to learn more.

`average(summary StatsSummary1D) RETURNS BIGINT`

`average_y(summary StatsSummary2D) RETURNS BIGINT`

`average_x(summary StatsSummary2D) RETURNS BIGINT`

Get the average of the values contained in a statistical aggregate.
In a two-dimensional `stats_agg`

use the `_y`

/ `_x`

form to access the
average of the dependent and independent variables.

For more information about statistical aggregate functions, see the hyperfunctions documentation.

## Required arguments

Name | Type | Description |
---|---|---|

`summary` | `StatsSummary1D` /`StatsSummary2D` | The already constructed data structure from a previous `stats_agg` call |

## Returns

Column | Type | Description |
---|---|---|

`average` /`average_y` /`average_x` | `DOUBLE PRECISION` | The average of the values in the statistical aggregate |

## Sample usage

```
SELECT average(stats_agg(data))
FROM generate_series(0, 100) data;
```

```
average
-----------
50
```

Found an issue on this page?

Report an issue!Keywords