其中count(distinct date_format(lastlogon,'%Y-%m-%d'))代表按照年月日去重后的次数。
max(lastlogon)代表最大的登录时间,也就是最近的登录时间。
select CAST(startTime AS DATE) startTime,count(*) as a,sum(case when serviceType='转办' then 1 else 0 end ) as b,
sum(case when endTime>now() then 1 else 0 end ) as c,
sum(case when callType='重复投诉' then 1 else 0 end ) as d,
sum(case when callType='咨询' then 1 else 0 end ) as e,
sum(case when callType='投诉举报' then 1 else 0 end ) as f,
sum(case when callType='求助' then 1 else 0 end ) as j,
sum(case when callType='建议' then 1 else 0 end ) as m,
sum(case when callType='表扬' then 1 else 0 end ) as n,
sum(case when callType='感谢' then 1 else 0 end ) as z
from opeform where startTime>='2015-6-1' and startTime<='2015-11-1'
group by CAST(startTime AS DATE)
这样改试一下
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)