标签:
数据抽取
将几张表中的数据放到一张表中
select s_cycle_date as f_date,roam_prov_id,mdn,mdn_city_id into tmp_qgj_sqmy from mpm00005 where roam_prov_id<>1 and mdn_city_id=9 insert into tmp_qgj_sqmy select s_cycle_date as f_date,roam_prov_id,mdn,mdn_city_id from mpm00006 where roam_prov_id<>1 and mdn_city_id=9 insert into tmp_qgj_sqmy select s_cycle_date as f_date,roam_prov_id,mdn,mdn_city_id from mpm00007 where roam_prov_id<>1 and mdn_city_id=9 insert into tmp_qgj_sqmy select s_cycle_date as f_date,roam_prov_id,mdn,mdn_city_id from mpm00008 where roam_prov_id<>1 and mdn_city_id=9 insert into tmp_qgj_sqmy select s_cycle_date as f_date,roam_prov_id,mdn,mdn_city_id from mpm00009 where roam_prov_id<>1 and mdn_city_id=9 insert into tmp_qgj_sqmy select s_cycle_date as f_date,roam_prov_id,mdn,mdn_city_id from mpm00010 where roam_prov_id<>1 and mdn_city_id=9 insert into tmp_qgj_sqmy select s_cycle_date as f_date,roam_prov_id,mdn,mdn_city_id from mpm00011 where roam_prov_id<>1 and mdn_city_id=9
2.数据分析
宿迁用户在省内地市分布情况
select count(distinct mdn)*5,cdr_city_id from tmp_gqj_sqwd group by cdr_city_id select f_date,sum(num) from (select f_date,case when mdn_prov_id =1 then count(1)*5 else count(1)*8 end as num from (select f_date,mdn,mdn_prov_id from tmp_gqj_suqian a group by f_date,mdn,mdn_prov_id) T group by f_date,mdn_prov_id) T2 group by f_date
标签:
原文地址:http://my.oschina.net/u/1866459/blog/514483