SELECT
(SELECT COUNT(1) FROM tbl_police WHERE TO_CHAR(created_on, 'yyyy') = TO_CHAR(now(), 'yyyy')) yearCount,
(SELECT COUNT(1) FROM tbl_police WHERE TO_CHAR(created_on, 'yyyy') = TO_CHAR(now()::TIMESTAMP+'-1 year', 'yyyy')) lastYearCount,
(SELECT COUNT(1) FROM tbl_police WHERE created_on::DATE = CURRENT_DATE) todayCount,
(SELECT COUNT(1) FROM tbl_police WHERE created_on::DATE = CURRENT_DATE - 1) yesterdayCount
FROM tbl_police
LIMIT 1
统计年月日的数据
最新推荐文章于 2024-08-25 22:36:40 发布