Need suggestion for a query.One solution is create a days table for all months.
I am trying to get count(c3.id)
for all days of month February
.
As in cs.created_at
, some dates are missing, how can I use below clause.
group by day(cs.created_at)
something like group by day(month(cs.created_at))
not working..
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)
Please provide the day(cs.created_at) in the select statement.
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.