Versions:

# num_vals() 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.

`num_vals(summary StatsSummary1D) RETURNS BIGINT`

`num_vals(summary StatsSummary2D) RETURNS BIGINT`

Get the number of values contained in a statistical aggregate. This saves space
when you need both a count and other statistical aggregates as part of a continuous
aggregate. You do not need to specify a separate `count`

aggregate.

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

`num_vals` | `BIGINT` | The number of values in the stats agg |

## Sample usage

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

```
num_vals
-----------
101
```

Found an issue on this page?

Report an issue!