> ## 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 timevectors into a single timevector for re-aggregation

<Icon icon="flask" /> Early access [1.3.0][toolkit-1.3.0]

Combine multiple pre-constructed timevectors into a single timevector. This is useful for re-aggregating timevectors that were created separately, such as when grouping by different dimensions or combining data from multiple sources.

## Samples

### Combine timevectors from different groups

Aggregate per-device timevectors into a single combined timevector:

```sql theme={"dark"}
CREATE TABLE samples(time TIMESTAMPTZ, batch INT, data DOUBLE PRECISION);

-- Create timevectors per batch
CREATE VIEW batch_series AS
    SELECT batch, timevector(time, data) AS batch_series
    FROM samples
    GROUP BY batch;

-- Combine all batches into one timevector
SELECT rollup(batch_series)
FROM batch_series;
```

### Re-aggregate across partitions

Combine timevectors from different time ranges:

```sql theme={"dark"}
CREATE VIEW daily_series AS
    SELECT
        date_trunc('day', time) AS day,
        timevector(time, temperature) AS series
    FROM sensor_data
    GROUP BY 1;

-- Get weekly timevector from daily timevectors
SELECT
    date_trunc('week', day) AS week,
    rollup(series) AS weekly_series
FROM daily_series
GROUP BY 1;
```

## Arguments

The syntax is:

```sql theme={"dark"}
rollup(
    series Timevector
) RETURNS Timevector
```

| Name   | Type       | Default | Required | Description                                          |
| ------ | ---------- | ------- | -------- | ---------------------------------------------------- |
| series | Timevector | -       | ✔        | Previously constructed timevector objects to combine |

## Returns

| Column | Type       | Description                                      |
| ------ | ---------- | ------------------------------------------------ |
| rollup | Timevector | A timevector combining all the underlying series |

[timevector]: /api-reference/timescaledb-toolkit/timevector/timevector

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