> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify-poc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# rollup()

> Combine multiple frequency aggregates

<Icon icon="tag" iconType="duotone" /> Since [1.16.0][toolkit-1.16.0]

Combine multiple aggregates created with `freq_agg` or `mcv_agg` functions. This function requires that the source
aggregates have been created with the same parameters (same `min_freq` for `freq_agg`, same n-factor and `skew`, if
used, for a `mcv_agg`).

This produces a very similar aggregate to running the same aggregate function over all the source data. In most cases,
any difference is no more than what you might get from simply reordering the input. However, if the source data for the
different aggregates is very differently distributed, the rollup result may have looser frequency bounds.

## Arguments

The syntax is:

```sql theme={"dark"}
rollup(
    agg SpaceSavingAggregate
) RETURNS SpaceSavingAggregate
```

| Name  | Type                 | Default | Required | Description                                                                       |
| ----- | -------------------- | ------- | -------- | --------------------------------------------------------------------------------- |
| `agg` | SpaceSavingAggregate | -       | ✔        | The aggregates to roll up. These must have been created with the same parameters. |

## Returns

| Column   | Type                 | Description                                                                                                 |
| -------- | -------------------- | ----------------------------------------------------------------------------------------------------------- |
| `rollup` | SpaceSavingAggregate | An aggregate containing the most common elements from all of the underlying data for all of the aggregates. |

[toolkit-1.16.0]: https://github.com/timescale/timescaledb-toolkit/releases/tag/1.16.0
