Versions:

# sum(), sum_y(), and sum_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.

`sum(summary StatsSummary1D, method TEXT) RETURNS BIGINT`

`sum_y(summary StatsSummary2D, method TEXT) RETURNS BIGINT`

`sum_x(summary StatsSummary2D, method TEXT) RETURNS BIGINT`

Get the sum of the values contained in a statistical aggregate.

In a two-dimensional `stats_agg`

use the `_y`

/ `_x`

form to access the
`sum`

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 |
---|---|---|

`sum` /`sum_y` /`sum_x` | `DOUBLE PRECISION` | The standard deviation of the values in the statistical aggregate |

## Sample usage

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

```
sum_y
-------
5050
```

Found an issue on this page?

Report an issue!Keywords