gpt4 book ai didi

Mysql:获取一个月中的所有天数

转载 作者:行者123 更新时间:2023-11-30 00:36:21 24 4
gpt4 key购买 nike

需要查询建议。一种解决方案是为所有月份创建一个天表。

我正在尝试获取 二月 月份所有天数的 count(c3.id)
正如在 cs.created_at 中一样,缺少一些日期,我如何使用下面的子句。

group by day(cs.created_at)

诸如按天分组(月(cs.created_at))之类的东西不起作用..

 select count(case when cs.id IN(select max(id) from complaint3_status
where complaint_id=c3.id and status_type=10)
and cs.status_value=11 then c3.id end
) as resolved_complaints
from complaint3 c3, complaint3_status cs,
company c, complaint3_details cd, user3 u3
where c3.id=cs.complaint_id
and cd.complaint_id=c3.id
and u3.id=c3.user_id
and c.id=c3.company_id
and c3.company_id=852
and month(cs.created_at)=02
and year(cs.created_at)=2014
group by day(cs.created_at)

最佳答案

请在 select 语句中提供日期 (cs.created_at)。

 select day(cs.created_at),count(case when cs.id IN(select max(id) from complaint3_status where complaint_id=c3.id  and status_type=10) and
cs.status_value=11 then c3.id end) as resolved_complaints
from complaint3 c3 , complaint3_status cs,
company c,complaint3_details cd,user3 u3 where c3.id=cs.complaint_id and cd.complaint_id=c3.id and
u3.id=c3.user_id and c.id=c3.company_id and c3.company_id=852 and month(cs.created_at)=02 and year(cs.created_at)=2014 group by day(cs.created_at)

关于Mysql:获取一个月中的所有天数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22146282/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com