基于postgresql中的每N天进行分组

f.a*_*uri 3 postgresql time aggregation window-functions

我有一张表,其中包括ID,日期,值(温度)和其他一些东西.我的表看起来像这样:

+-----+--------------+------------+
| ID  |  temperature |    Date    |
+-----+--------------+------------+
|  1  |  26.3        | 2012-02-05 |
|  2  |  27.8        | 2012-02-06 |
|  3  |  24.6        | 2012-02-07 |
|  4  |  29.6        | 2012-02-08 |
+-----+--------------+------------+
Run Code Online (Sandbox Code Playgroud)

我想每10天执行一次汇总查询,例如sum和mean.

我想知道是否有可能在psql中?

Clo*_*eto 8

SQL小提琴

select
    "date",
    temperature,
    avg(temperature) over(order by "date" rows 10 preceding) mean
from t
order by "date"
Run Code Online (Sandbox Code Playgroud)