SELECTmc ,COUNT(1) AS sl ,SUM(CASE WHEN rq >= '2015-2-1' THEN 1 ELSE 0 END) AS 符合条件数量 ,SUM(CASE WHEN rq<'2015-2-1' THEN 1 ELSE 0 END) AS 不符合条件数量
FROM TabName
GROUP BY mc
select mc,COUNT(*) as rq,SUM(case when rq>='2015-2-1' then 1 else 0 end) as 符合条件数量, SUM(case when rq<'2015-2-1' then 1 else 0 end) as不符合条件数量 from 表 group by mc