这是我的sql 语句:
SELECT job_addrc,date_format(job_time,'%Y-%m-%d') as regdate,
sum(case job_status when 50 then 1 else 0 end) as us50,
sum(case job_status when 60 then 1 else 0 end) as us60,
sum(case job_status when 70 then 1 else 0 end) as us70,
sum(case job_status when 80 then 1 else 0 end) as us80
FROM job_info where job_time between '2001-1-22' and '2009-2-25'
group by regdate,job_addrc order by regdate desc ;
得到的结果是这样的:
job_addrc regdate us50 us60 us70 us80
'530', '2009-02-23', 0, 0, 3, 0
'531', '2009-02-23', 0, 0, 0, 0
'538', '2009-02-23', 0, 0, 0, 0
'565', '2009-02-23', 0, 0, 0, 0
'576', '2009-02-23', 0, 0, 0, 0
'593', '2009-02-23', 0, 0, 0, 0
'600', '2009-02-23', 0, 0, 1, 0
'635', '2009-02-23', 0, 0, 3, 0
'639', '2009-02-23', 0, 0, 0, 0
'652', '2009-02-23', 0, 0, 0, 0
'653', '2009-02-23', 0, 0, 0, 0
'654', '2009-02-23', 0, 0, 1, 0
'664', '2009-02-23', 0, 0, 0, 0
'690', '2009-02-23', 0, 0, 0, 0
'702', '2009-02-23', 1, 0, 0, 0
'703', '2009-02-23', 0, 0, 1, 0
我想要的结果是 us50 us60 us70 us80 这四个的不同时为0的数据
'531', '2009-02-23', 0, 0, 0, 0
'538', '2009-02-23', 0, 0, 0, 0
'565', '2009-02-23', 0, 0, 0, 0
'576', '2009-02-23', 0, 0, 0, 0
这样的数据是我不要的,在sql语句中我应该怎么过滤掉他们呢。
在线等啊。 |