postgresql 如何显示一个月中每天的COUNT

vaj7vani  于 2022-12-29  发布在  PostgreSQL
关注(0)|答案(1)|浏览(211)

使用Postgresql

SELECT 

    COUNT(visit.visit_disch_date)
    FROM
    visit
WHERE
 visit.visit_disch_date >= '2022-12-01' AND visit.visit_disch_date < '2022-12-31' AND 
    visit.visit_stay_type = '1'

我试图得到十二月每一天的个体计数,输出如下所示:
二○二二年一月十二日4
二○二二年二月十二日5
二○二二年三月十二日7

k5ifujac

k5ifujac1#

SELECT 
  DATE(visit.visit_disch_date) as Date_of_Discharge,
    COUNT(visit.visit_disch_date) AS Number_of_Discharges
    FROM
    visit
    WHERE
    visit.visit_disch_date BETWEEN '2022-12-01' AND '2022-12-31' AND
    visit.visit_stay_type = '1'
    GROUP BY
    DATE(visit.visit_disch_date)

相关问题