日期:2014-05-17 浏览次数:20892 次
select aa.fixed_net,aa.school_net,aa.differ_net,aa.wlan_net,aa.other_net,aa.city_name,
aa.oneType_user,aa.twoType_user,aa.threeType_user,aa.other_user,
aa.local_rom,aa.out_rom,aa.in_rom ,aa.nation_out_rom,aa.nation_in_rom from
(select
'city_name' = '写死的',
'fixed_net' = sum(case a.id when 1 then a.num else 0 end ) ,
'school_net' = sum(case a.id when 3 then a.num else 0 end ),
'differ_net' = sum(case a.id when 4 then a.num else 0 end ),
'wlan_net' = sum(case a.id when 5 then a.num else 0 end ),
'other_net' = sum(case a.id when 0 then a.num else 0 end ),
'oneType_user' = sum(case b.id when 1 then b.num else 0 end ) ,
'twoType_user' = sum(case b.id when 2 then b.num else 0 end ),
'threeType_user' = sum(case b.id when 3 then b.num else 0 end ),
'other_user' = sum(case b.id when 99 then b.num else 0 end ),
'local_rom' = sum(case c.id when 0 then c.num else 0 end ),
'out_rom' = sum(case c.id when 1 then c.num else 0 end ),
'in_rom' = sum(case c.id when 2 then c.num else 0 end ),
'nation_out_rom' = sum(case c.id when 3 then c.num else 0 end ),
'nation_in_rom' = sum(case c.id when 5 then c.num else 0 end )
from
(select count(user_id) as num,certify_user_type as id
from ${tableName} where certify_user_type not in (2) and city_id in ('001','002','003') //此处的数据是动态的
group by certify_user_type
) a
,
( select count(user_id) as num ,user_type_id as id
from ${tableName}
where user_type_id in (1,2,3,99) and certify_user_type=2 and city_id in ('001','002','003')
group by user_type_id
) b
,
( select count(user_id) as num,romflag as id
from ${tableName} where city_id in ('001','002','003')
group by romflag
) c
) aa
select
'city_name' = '写死的',
'fixed_net' = sum(case certify_user_type when 1 then 1 else 0 end ) ,
'school_net' = sum(case certify_user_type when 3 then 1 else 0 end ),
'differ_net' = sum(case certify_user_type when 4 then 1 else 0 end ),
'wlan_net' = sum(case certify_user_type when 5 then 1 else 0 end ),
'other_net' = sum(case certify_user_type when 0 then 1 else 0 end ),
'oneType_user' = sum(case when user_type_id=1 and certify_user_type<>2 then 1 else 0 end ) ,
'twoType_user' = sum(case when user_type_id=2 and certify_user_type<>2 then b.num else 0 end ),
'threeType_user' = sum(case when user_type_id=3 and certify_user_type<>2 then 1 else 0 end ),
'other_user' = sum(case when user_type_id=99 and certify_user_type<>2 then 1 else 0 end ),
'local_rom' = sum(case romflag when 0 then 1 else 0 end ),
'out_rom' = sum(case romflag when 1 then 1 else 0 end ),
'in_rom' = sum(case romflag when 2 then 1 else 0 end ),
'nation_out_rom