SELECT m.minute , COALESCE(sum(c.minute_ct) OVER (ORDER BY m.minute), 0) AS running_ctFROM ( SELECT generate_series(date_trunc('minute', min("when")) , max("when") , interval '1 min') FROM tbl ) m(minute)LEFT JOIN ( SELECT date_trunc('minute', "when") AS minute , count(*) AS minute_ct FROM tbl GROUP BY 1 ) c USING (minute)ORDER BY 1; 这篇关于PostgreSQL:按分钟运行查询的行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-13 05:01