【发布时间】:2023-04-04 09:42:01
【问题描述】:
考虑一个有 2 列的表格:
create table foo
(
ts timestamp,
precipitation numeric,
primary key (ts)
);
使用以下数据:
| ts | precipitation |
|---|---|
| 2021-06-01 12:00:00 | 1 |
| 2021-06-01 13:00:00 | 0 |
| 2021-06-01 14:00:00 | 2 |
| 2021-06-01 15:00:00 | 3 |
我想使用TimescaleDB continuous aggregate 来计算每小时计算一次的此数据的三小时累积总和。使用上面的示例数据,我的连续聚合将包含
| ts | cum_precipitation |
|---|---|
| 2021-06-01 12:00:00 | 1 |
| 2021-06-01 13:00:00 | 1 |
| 2021-06-01 14:00:00 | 3 |
| 2021-06-01 15:00:00 | 5 |
我看不到使用支持的连续聚合语法来执行此操作的方法。我错过了什么吗?本质上,我希望时间段是前面的 x 小时,但计算每小时发生一次。
【问题讨论】:
标签: sql postgresql timescaledb