需要建议查询。一种解决方案是为所有月份创建一个日期表。
我想在count(c3.id)
的所有日子里February
获得cs.created_at
与group by day(cs.created_at)
中一样,缺少某些日期,我如何使用以下条款。
group by day(month(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)
这样的东西不起作用..
{{1}}
答案 0 :(得分:0)
请在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)