56,675
社区成员
发帖
与我相关
我的任务
分享
select time,week,az,xz,op from (
select b.time as time ,b.week as week,
SUM(case b.status when 'az' then b.counts else 0 end ) as 'az',
SUM(case b.status when 'xz' then b.counts else 0 end ) as 'xz',
SUM(case b.status when 'open' then b.counts else 0 end ) as 'op' from (
select status,time,week,COUNT(status) as counts from (
select distinct status,time,week,ip from kp_statistics where
TO_DAYS(NOW()) - TO_DAYS(time) <= 50 and time!='2014-06-16' and
(status = 'az' or status = 'xz' or status = 'open') group by status,time,week,ip
) a group by status,time ,week
) b group by b.time ,b.week order by time desc
)t where TO_DAYS(NOW()) - TO_DAYS(time) <= 50 and time!='2014-06-16' limit 0,30