0
点赞
收藏
分享

微信扫一扫

postgresql 按小时统计

后来的六六 2023-12-13 阅读 10

环境

postgresql-14

按小时统计业务

SELECT
 count(1),
 to_char(gmt_create, 'YYYY-MM-DD  HH24' ) AS d
FROM
 table_name
WHERE
gmt_create >'2023-12-13 11:30:00'
GROUP BY d
ORDER BY d

按天统计

SELECT
 count(1),
 to_char(gmt_create, 'yyyy-MM-dd' ) AS d
FROM
 table_name
WHERE
gmt_create BETWEEN '2022-11-01' and '2022-11-12'
GROUP BY d
ORDER BY d

按分钟统计

SELECT
 count(1),
 to_char(gmt_create, 'HH24-mi' ) AS d
FROM
 table_name
WHERE
gmt_create >'2023-12-13 11:30:00'
GROUP BY d
ORDER BY d
举报

相关推荐

0 条评论