我做了一张桌子
create table counter (
createdat TIMESTAMP,
tickets INT,
id VARCHAR
)
我想以 15 分钟的间隔对行进行分组,所以我试图这样做:
SELECT
SUM(tickets) AS total,
extract(year from createdat),
extract(month from createdat),
extract(day from createdat),
extract(hour from createdat)
from counter
where id = ?
group by
extract(year from createdat),
extract(month from createdat),
extract(day from createdat),
extract(hour from createdat)
通过这个查询,我只能按小时获得。但是我无法将其修改为几分钟。
查询如何按 15 分钟的间隔分组?