日期:2014-05-17 浏览次数:21120 次
select u.unitname, m.* from unit_info_tab u, (select count(*) as total, b.unitid as unitid,
sum(case when b.stateid ='3' then 1 else 0 end) as weiwancheng,
sum(case when b.stateid in ('1','6') then 1 else 0 end) as wancheng,
sum(case when a.eventnum Like '0101%' then 1 else 0 end) as shironghuanjing,
sum(case when a.eventnum Like '0102%' then 1 else 0 end) as xuanchuanguanggao,
sum(case when a.eventnum Like '0103%' then 1 else 0 end) as shigongguanli,
sum(case when a.eventnum Like '0105%' then 1 else 0 end) as jiemianzhixu,
sum(case when a.eventnum Like '0104%' then 1 else 0 end) as tufashijian,
sum(case when a.eventnum in ('0201%','0202%','0203%','0204%','0205%','0206%') then 1 else 0 end) as bujian,
sum(case when a.eventnum Like '05%' then 1 else 0 end) as other,
sum(case when a.eventnum Like '03%' then 1 else 0 end) as zhianfangkong,
sum(case when b.stateid in ('6') then 1 else 0 end) as daxunhuan,
(count(*) - sum(case when b.stateid in ('6') then 1 else 0 end)) as xiaoxunhuan