当前位置: 首页 > news >正文

20230215_数据库过程_高质量发展

高质量发展

—一、运营结果

SQL_STRING:=‘delete shzc.np_rec_lnpdb a
where exists (select * from tbcs.v_np_rec_lnpdb@bcv t where a.telnum=t.telnum
and a.outcarrier=t.OUTCARRIER
and a.incarrier=t.INCARRIER
and a.owncarrier=t.OWNCARRIER
and a.starttime=t.STARTTIME
and a.status<>t.status )’;
EXECUTE IMMEDIATE (SQL_STRING);
commit;

SQL_STRING:=‘insert into shzc.np_rec_lnpdb
select t.region,t.telnum,zhyw.shzc_hdpd_tscl(t.telnum) 号码资源情况,
t.OUTCARRIER,decode(substr(t.OUTCARRIER,1,3),’‘001’‘,’‘电信’‘,’‘002’‘,’‘移动’‘,’‘003’‘,’‘联通’‘) 携出运营商,
t.INCARRIER,decode(substr(t.INCARRIER,1,3),’‘001’‘,’‘电信’‘,’‘002’‘,’‘移动’‘,’‘003’‘,’‘联通’‘) 携入运营商,
t.OWNCARRIER,decode(substr(t.OWNCARRIER,1,3),’‘001’‘,’‘电信’‘,’‘002’‘,’‘移动’‘,’‘003’‘,’‘联通’‘) 归属运营商,
t.STARTTIME,t.ENDTIME,t.TRANSTYPE,t.STATUS,t.ISNEW,t.AUDITTIME
from tbcs.v_np_rec_lnpdb@bcv t
where not exists (select * from shzc.np_rec_lnpdb a where a.telnum=t.telnum
and a.outcarrier=t.OUTCARRIER
and a.incarrier=t.INCARRIER
and a.owncarrier=t.OWNCARRIER
and a.starttime=t.STARTTIME)’;
EXECUTE IMMEDIATE (SQL_STRING);
commit;

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx’),‘SHZC’);
SQL_STRING:=‘create table shzc.sm_gzl_gzl_hmmx as
select a.region,a.telnum,a.携出运营商,a.携入运营商,a.归属运营商,a.starttime,a.endtime,a.transtype,a.status,a.isnew,
nvl(case when a.携入运营商=’‘移动’’ then ‘‘携入’’ when a.携出运营商=‘‘移动’’ then ‘‘携出’’ end,‘‘其他’’) 类型
from shzc.np_rec_lnpdb a
where a.region=‘‘533’’
and a.starttime-1 <to_date(‘’‘||P_DAY||’‘’,‘‘yyyymmdd’’)';
EXECUTE IMMEDIATE (SQL_STRING);

—携入 状态时间与开户时间最近

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xr’),‘SHZC’);
SQL_STRING:=‘create table shzc.sm_gzl_gzl_hmmx_xr as
select * from
(select a.subsid,a.nettype,a.servnumber,a.prodid,a.createdate,a.status,a.statusdate,b.starttime,
row_number() over (partition by a.servnumber,b.starttime order by a.createdate ) 排名
from zhyw.subscriber a,
(select distinct b.telnum,b.starttime from shzc.sm_gzl_gzl_hmmx b where b.类型=’‘携入’‘) b
where a.servnumber=b.telnum
and to_char(a.createdate,’‘yyyymmdd’‘)>=to_char(b.starttime,’‘yyyymmdd’‘)) a
where 排名=1’;
EXECUTE IMMEDIATE (SQL_STRING);

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xra’),‘SHZC’);
SQL_STRING:=‘create table shzc.sm_gzl_gzl_hmmx_xra as
select b.*,a.subsid, a.nettype,a.servnumber,a.prodid,a.createdate,a.status,
a.statusdate,a.排名
from
(select distinct b.telnum,b.starttime,b.类型 from shzc.sm_gzl_gzl_hmmx b where b.类型=’‘携入’‘) b,
shzc.sm_gzl_gzl_hmmx_xr a
where b.telnum=a.servnumber(+)
and b.starttime=a.starttime(+)’;
EXECUTE IMMEDIATE (SQL_STRING);

----写入本地存档----留档
SQL_STRING:=‘insert into shzc.sm_gzl_gzl_hmmx_xrbd
select * from shzc.sm_gzl_gzl_hmmx_xra a
where not exists ( select 1 from shzc.sm_gzl_gzl_hmmx_xrbd b
where b.telnum=a.telnum
and b.subsid=a.subsid
and b.starttime=a.starttime)’;
EXECUTE IMMEDIATE (SQL_STRING);
commit;

—携出 状态时间与开户时间最近

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xc’),‘SHZC’);
SQL_STRING:=‘create table shzc.sm_gzl_gzl_hmmx_xc as
select * from
(select a.subsid,a.nettype,a.servnumber,a.prodid,a.createdate,a.status,a.statusdate,b.starttime,
row_number() over (partition by a.servnumber,b.starttime order by a.createdate desc,STATUSDATE desc ) 排名
from zhyw.subscriber a,
(select distinct b.telnum,b.starttime from shzc.sm_gzl_gzl_hmmx b where b.类型=’‘携出’‘) b
where a.servnumber=b.telnum
and to_char(a.createdate,’‘yyyymmdd’‘)<=to_char(b.starttime,’‘yyyymmdd’‘)) a
where 排名=1’;
EXECUTE IMMEDIATE (SQL_STRING);

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xca’),‘SHZC’);
SQL_STRING:=‘create table shzc.sm_gzl_gzl_hmmx_xca as
select b.*,a.subsid, a.nettype,a.servnumber,a.prodid,a.createdate,a.status,
a.statusdate,a.排名
from
(select distinct b.telnum,b.starttime,b.类型 from shzc.sm_gzl_gzl_hmmx b where b.类型=’‘携出’‘) b,
shzc.sm_gzl_gzl_hmmx_xc a
where b.telnum=a.servnumber(+)
and b.starttime=a.starttime(+)’;
EXECUTE IMMEDIATE (SQL_STRING);

----写入本地存档----留档
SQL_STRING:=‘insert into shzc.sm_gzl_gzl_hmmx_xcbd
select * from shzc.sm_gzl_gzl_hmmx_xca a
where not exists ( select 1 from shzc.sm_gzl_gzl_hmmx_xcbd b
where b.telnum=a.telnum
and b.subsid=a.subsid
and b.starttime=a.starttime)’;
EXECUTE IMMEDIATE (SQL_STRING);
commit;

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xzhz’),‘SHZC’);
SQL_STRING:='create table shzc.sm_gzl_gzl_hmmx_xzhz as
select * from shzc.sm_gzl_gzl_hmmx_xrbd a
union all
select * from shzc.sm_gzl_gzl_hmmx_xcbd a ';
EXECUTE IMMEDIATE (SQL_STRING);

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xzhm’),‘SHZC’);
SQL_STRING:=‘create table shzc.sm_gzl_gzl_hmmx_xzhm as
select a.region,a.telnum,a.携出运营商,a.携入运营商,a.starttime,a.transtype,a.类型,
b.subsid,b.nettype,b.servnumber,b.prodid,b.createdate,b.status,b.statusdate,c.ownerorgid,c.registerorgid,
ceil(nvl(case when b.status=’‘US10’’ then to_date(to_char(a.starttime,‘‘yyyymm’’)||substr(‘’‘||P_DAY||’‘’,7,2),‘‘yyyymmdd’’) + 1 end,b.statusdate)-b.createdate) 网龄天数,
nvl(case when nvl(substr(c.ownerorgid,8,1),‘‘0’’) not in (select t.county_id from zhyw.rpt_county t
where t.county_id not in (‘‘0’’,‘‘A’’,‘‘zbtyqd’’)) then ‘‘x’’ end,substr(c.ownerorgid,8,1)) qx,
nvl(case when nvl(b.createdate,sysdate) > sysdate - 31 then 1 end ,0) 近期入网
from shzc.sm_gzl_gzl_hmmx a,
shzc.sm_gzl_gzl_hmmx_xzhz b,
zhyw.subscriber c
where a.类型 in (‘‘携入’’,‘‘携出’’)
and b.subsid=c.subsid(+)
and a.telnum=b.telnum(+)
and a.starttime=b.starttime(+)
and a.类型=b.类型(+)
and to_char(a.starttime,‘‘yyyymm’’)>=
to_char(add_months(to_date(substr(‘’‘||v_monsr||’‘’,1,6),‘‘yyyymm’’),-3),‘‘yyyymm’’)';
EXECUTE IMMEDIATE (SQL_STRING);

----携入网龄按照过网时间

----携入会增加本月发展号码,所以需要插入上月底过网情况与截至昨天的过网情况
SQL_STRING:=‘insert into shzc.sm_gzl_gzl_hmmx_xrgw_day
select d.op_time,d.comp_product_no,to_date(d.open_date3,’‘yyyy-mm-dd’‘) open_date3,
to_date(d.last_date3,’‘yyyy-mm-dd’‘) last_date3,to_number(d.net_age) net_age
from zibo.DW_USER_NET_AGE_’||v_last_day3||’ d,
(select distinct b.telnum from shzc.sm_gzl_gzl_hmmx_xzhm b where b.类型=‘‘携入’’) b
where d.comp_product_no=b.telnum
and not exists (select 1 from shzc.sm_gzl_gzl_hmmx_xrgw_day t
where t.comp_product_no=d.comp_product_no
and t.open_date3=to_date(d.open_date3,‘‘yyyy-mm-dd’’))
union all
select d.op_time,d.comp_product_no,to_date(d.open_date3,‘‘yyyy-mm-dd’’) open_date3,
to_date(d.last_date3,‘‘yyyy-mm-dd’’) last_date3,to_number(d.net_age) net_age
from zibo.DW_USER_NET_AGE_‘||v_last_day2||’ d,
(select distinct b.telnum from shzc.sm_gzl_gzl_hmmx_xzhm b where b.类型=‘‘携入’’) b
where d.comp_product_no=b.telnum
and not exists (select 1 from shzc.sm_gzl_gzl_hmmx_xrgw_day t
where t.comp_product_no=d.comp_product_no
and t.open_date3=to_date(d.open_date3,‘‘yyyy-mm-dd’’))
union all
select d.op_time,d.comp_product_no,to_date(d.open_date3,‘‘yyyy-mm-dd’’) open_date3,
to_date(d.last_date3,‘‘yyyy-mm-dd’’) last_date3,to_number(d.net_age) net_age
from zibo.DW_USER_NET_AGE_‘||v_last_day||’ d,
(select distinct b.telnum from shzc.sm_gzl_gzl_hmmx_xzhm b where b.类型=‘‘携入’’) b
where d.comp_product_no=b.telnum
and not exists (select 1 from shzc.sm_gzl_gzl_hmmx_xrgw_day t
where t.comp_product_no=d.comp_product_no
and t.open_date3=to_date(d.open_date3,‘‘yyyy-mm-dd’’))
union all
select d.op_time,d.comp_product_no,to_date(d.open_date3,‘‘yyyy-mm-dd’’) open_date3,
to_date(d.last_date3,‘‘yyyy-mm-dd’’) last_date3,to_number(d.net_age) net_age
from zibo.DW_USER_NET_AGE_‘||P_DAY||’ d,
(select distinct b.telnum from shzc.sm_gzl_gzl_hmmx_xzhm b where b.类型=‘‘携入’’) b
where d.comp_product_no=b.telnum
and not exists (select 1 from shzc.sm_gzl_gzl_hmmx_xrgw_day t
where t.comp_product_no=d.comp_product_no
and t.open_date3=to_date(d.open_date3,‘‘yyyy-mm-dd’’)) ';
EXECUTE IMMEDIATE (SQL_STRING);
commit;

-----他网号码最早过网时间

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xrgw_daya’),‘SHZC’);
SQL_STRING:=‘create table shzc.sm_gzl_gzl_hmmx_xrgw_daya as
select a.comp_product_no,min(a.open_date3) open_date3 from shzc.sm_gzl_gzl_hmmx_xrgw_day a
group by a.comp_product_no’;
EXECUTE IMMEDIATE (SQL_STRING);

----携入携出增加号码划归a/b/c1/c2/d 类情况。
—近三个月集团成员情况

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xrgw_jthf’),‘SHZC’);
SQL_STRING:=‘create table shzc.sm_gzl_gzl_hmmx_xrgw_jthf as
select ‘’’||v_monsrq2||‘’’ cycle,a.* from
(select a.custid,a.集团编号,a.集团名称,集团类型,a.subsid,a.servnumber,a.加入集团时间,
nvl(case when upper(substr(集团类型,1,1))=‘‘A’’ then ‘‘A’’
when upper(substr(集团类型,1,1))=‘‘B’’ then ‘‘B’’
when upper(substr(集团类型,1,1))=‘‘D’’ then ‘‘D’’ end,upper(substr(集团类型,1,2))) 集团类型结果,
row_number() over (partition by a.subsid order by a.加入集团时间 desc ) 排名
from zhyw.qcy_busscustsubs_‘||v_monsrq2||’ a,
(select distinct b.subsid from shzc.sm_gzl_gzl_hmmx_xzhm b ) b
where a.subsid=b.subsid) a
where a.排名=1
union all
select ‘’‘||v_monsrq||’‘’ cycle,a.* from
(select a.custid,a.集团编号,a.集团名称,集团类型,a.subsid,a.servnumber,a.加入集团时间,
nvl(case when upper(substr(集团类型,1,1))=‘‘A’’ then ‘‘A’’
when upper(substr(集团类型,1,1))=‘‘B’’ then ‘‘B’’
when upper(substr(集团类型,1,1))=‘‘D’’ then ‘‘D’’ end,upper(substr(集团类型,1,2))) 集团类型结果,
row_number() over (partition by a.subsid order by a.加入集团时间 desc ) 排名
from zhyw.qcy_busscustsubs_‘||v_monsrq||’ a,
(select distinct b.subsid from shzc.sm_gzl_gzl_hmmx_xzhm b ) b
where a.subsid=b.subsid) a
where a.排名=1
union all
select ‘’‘||v_monsr||’‘’ cycle,a.* from
(select a.custid,a.集团编号,a.集团名称,集团类型,a.subsid,a.servnumber,a.加入集团时间,
nvl(case when upper(substr(集团类型,1,1))=‘‘A’’ then ‘‘A’’
when upper(substr(集团类型,1,1))=‘‘B’’ then ‘‘B’’
when upper(substr(集团类型,1,1))=‘‘D’’ then ‘‘D’’ end,upper(substr(集团类型,1,2))) 集团类型结果,
row_number() over (partition by a.subsid order by a.加入集团时间 desc ) 排名
from zhyw.qcy_busscustsubs_‘||v_monsr||’ a,
(select distinct b.subsid from shzc.sm_gzl_gzl_hmmx_xzhm b ) b
where a.subsid=b.subsid) a
where a.排名=1’;
EXECUTE IMMEDIATE (SQL_STRING);

SQL_STRING:=‘delete shzc.sm_gzl_gzl_hmmx_xrgw_jthf_bd a where a.cycle=’‘’||v_monsr||‘’’ ';
EXECUTE IMMEDIATE (SQL_STRING);
commit;

SQL_STRING:='insert into shzc.sm_gzl_gzl_hmmx_xrgw_jthf_bd
select * from shzc.sm_gzl_gzl_hmmx_xrgw_jthf a
where not exists (select 1 from shzc.sm_gzl_gzl_hmmx_xrgw_jthf_bd t where t.cycle=a.cycle and t.subsid=a.subsid) ';
EXECUTE IMMEDIATE (SQL_STRING);
commit;

----取号码最后一个月最后一次的记录

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xrgw_jthfa’),‘SHZC’);
SQL_STRING:='create table shzc.sm_gzl_gzl_hmmx_xrgw_jthfa as
select * from
(select a.*,row_number() over (partition by a.subsid order by a.cycle desc,a.加入集团时间 desc ) z排名
from shzc.sm_gzl_gzl_hmmx_xrgw_jthf_bd a) a
where z排名=1 ';
EXECUTE IMMEDIATE (SQL_STRING);

----发展客户 ARPU 指 12 月发展客户在 1 月实际收入,流失客户 Arpu 指 2 月流失客户在 1 月实际收入;
----更新网龄天数,增加上月arpu,携入的按照当月现在时间计算,不然后续不好环比

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xzhmx’),‘SHZC’);
SQL_STRING:=‘create table shzc.sm_gzl_gzl_hmmx_xzhmx as
select a.*,b.open_date3,
ceil(nvl(case when a.status=’‘US10’’ then to_date(to_char(a.starttime,‘‘yyyymm’’)||substr(‘’‘||P_DAY||’‘’,7,2),‘‘yyyymmdd’’) + 1 end,a.statusdate)-
nvl(case when a.类型=‘‘携入’‘then nvl(b.open_date3,a.createdate) end,a.createdate)) 新网龄天数,
nvl(cs.arpu,0) arpu_sy,
nvl(c.arpu,0) arpu,
nvl(d.集团类型结果,’‘0’’) 集团类型结果,d.集团编号,d.集团名称,d.加入集团时间
from shzc.sm_gzl_gzl_hmmx_xzhm a,
shzc.sm_gzl_gzl_hmmx_xrgw_daya b,
zibo.Dw_product_‘||v_monsrq2||’ cs,
zibo.Dw_product_‘||v_monsrq||’ c,
shzc.sm_gzl_gzl_hmmx_xrgw_jthfa d
where a.telnum=b.comp_product_no(+)
and a.subsid=cs.user_id(+)
and a.subsid=c.user_id(+)
and a.subsid=d.subsid(+) ';
EXECUTE IMMEDIATE (SQL_STRING);

----增加区县编码与业务时间 主要基础表+++++

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xzhma’),‘SHZC’);
SQL_STRING:=‘create table shzc.sm_gzl_gzl_hmmx_xzhma as
select a.*,nvl(t.jf_county_id,’‘1008’‘) jf_county_id,nvl(t.name,’‘线上’‘) name,
to_char(a.starttime,’‘yyyymmdd’') startday
from shzc.sm_gzl_gzl_hmmx_xzhmx a,
zhyw.rpt_county t
where a.qx=t.county_id(+) ';
EXECUTE IMMEDIATE (SQL_STRING);

----第一个表生成数据

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xz_hz’),‘SHZC’);
SQL_STRING:=‘create table shzc.sm_gzl_gzl_hmmx_xz_hz as
select ‘’’||p_day||‘’’ cycle,a.qx,a.jf_county_id,a.name,
count(distinct case when a.类型=‘‘携入’’ and a.startday=‘’‘||p_day||’‘’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 日携入量,
count(distinct case when a.类型=‘‘携入’’ and a.startday=‘’‘||p_day||’‘’ and a.携出运营商=‘‘联通’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 日携入量_联通,
count(distinct case when a.类型=‘‘携入’’ and a.startday=‘’‘||p_day||’‘’ and a.携出运营商=‘‘电信’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 日携入量_电信,

count(distinct case when a.类型=‘‘携出’’ and a.startday=‘’‘||p_day||’‘’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 日携出量,
count(distinct case when a.类型=‘‘携出’’ and a.startday=‘’‘||p_day||’‘’ and a.携入运营商=‘‘联通’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 日携出量_联通,
count(distinct case when a.类型=‘‘携出’’ and a.startday=‘’‘||p_day||’‘’ and a.携入运营商=‘‘电信’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 日携出量_电信,

count(distinct case when a.类型=‘‘携入’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 月携入量,
count(distinct case when a.类型=‘‘携入’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.携出运营商=‘‘联通’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 月携入量_联通,
count(distinct case when a.类型=‘‘携入’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.携出运营商=‘‘电信’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 月携入量_电信,

count(distinct case when a.类型=‘‘携出’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 月携出量,
count(distinct case when a.类型=‘‘携出’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.携入运营商=‘‘联通’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 月携出量_联通,
count(distinct case when a.类型=‘‘携出’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.携入运营商=‘‘电信’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 月携出量_电信,

count(distinct case when a.类型=‘‘携入’’ and substr(a.startday,1,4)=‘’‘||v_yesr||’‘’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 年携入量,
count(distinct case when a.类型=‘‘携入’’ and substr(a.startday,1,4)=‘’‘||v_yesr||’‘’ and a.携出运营商=‘‘联通’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 年携入量_联通,
count(distinct case when a.类型=‘‘携入’’ and substr(a.startday,1,4)=‘’‘||v_yesr||’‘’ and a.携出运营商=‘‘电信’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 年携入量_电信,

count(distinct case when a.类型=‘‘携出’’ and substr(a.startday,1,4)=‘’‘||v_yesr||’‘’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 年携出量,
count(distinct case when a.类型=‘‘携出’’ and substr(a.startday,1,4)=‘’‘||v_yesr||’‘’ and a.携入运营商=‘‘联通’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 年携出量_联通,
count(distinct case when a.类型=‘‘携出’’ and substr(a.startday,1,4)=‘’‘||v_yesr||’‘’ and a.携入运营商=‘‘电信’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 年携出量_电信,
‘‘分割线’’ fen,-----------------------------------------------------------------------------
count(distinct case when a.类型=‘‘携入’’ and a.新网龄天数>=31 and a.startday=‘’‘||p_day||’‘’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_日携入量,
count(distinct case when a.类型=‘‘携入’’ and a.新网龄天数>=31 and a.startday=‘’‘||p_day||’‘’ and a.携出运营商=‘‘联通’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_日携入量_联通,
count(distinct case when a.类型=‘‘携入’’ and a.新网龄天数>=31 and a.startday=‘’‘||p_day||’‘’ and a.携出运营商=‘‘电信’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_日携入量_电信,

count(distinct case when a.类型=‘‘携出’’ and a.新网龄天数>=31 and a.startday=‘’‘||p_day||’‘’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_日携出量,
count(distinct case when a.类型=‘‘携出’’ and a.新网龄天数>=31 and a.startday=‘’‘||p_day||’‘’ and a.携入运营商=‘‘联通’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_日携出量_联通,
count(distinct case when a.类型=‘‘携出’’ and a.新网龄天数>=31 and a.startday=‘’‘||p_day||’‘’ and a.携入运营商=‘‘电信’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_日携出量_电信,

count(distinct case when a.类型=‘‘携入’’ and a.新网龄天数>=31 and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_月携入量,
count(distinct case when a.类型=‘‘携入’’ and a.新网龄天数>=31 and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.携出运营商=‘‘联通’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_月携入量_联通,
count(distinct case when a.类型=‘‘携入’’ and a.新网龄天数>=31 and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.携出运营商=‘‘电信’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_月携入量_电信,

count(distinct case when a.类型=‘‘携出’’ and a.新网龄天数>=31 and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_月携出量,
count(distinct case when a.类型=‘‘携出’’ and a.新网龄天数>=31 and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.携入运营商=‘‘联通’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_月携出量_联通,
count(distinct case when a.类型=‘‘携出’’ and a.新网龄天数>=31 and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.携入运营商=‘‘电信’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_月携出量_电信,

count(distinct case when a.类型=‘‘携入’’ and a.新网龄天数>=31 and substr(a.startday,1,4)=‘’‘||v_yesr||’‘’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_年携入量,
count(distinct case when a.类型=‘‘携入’’ and a.新网龄天数>=31 and substr(a.startday,1,4)=‘’‘||v_yesr||’‘’ and a.携出运营商=‘‘联通’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_年携入量_联通,
count(distinct case when a.类型=‘‘携入’’ and a.新网龄天数>=31 and substr(a.startday,1,4)=‘’‘||v_yesr||’‘’ and a.携出运营商=‘‘电信’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_年携入量_电信,

count(distinct case when a.类型=‘‘携出’’ and a.新网龄天数>=31 and substr(a.startday,1,4)=‘’‘||v_yesr||’‘’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_年携出量,
count(distinct case when a.类型=‘‘携出’’ and a.新网龄天数>=31 and substr(a.startday,1,4)=‘’‘||v_yesr||’‘’ and a.携入运营商=‘‘联通’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_年携出量_联通,
count(distinct case when a.类型=‘‘携出’’ and a.新网龄天数>=31 and substr(a.startday,1,4)=‘’‘||v_yesr||’‘’ and a.携入运营商=‘‘电信’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_年携出量_电信
from shzc.sm_gzl_gzl_hmmx_xzhma a
group by a.qx,a.jf_county_id,a.name
union all
select ‘’‘||p_day||’‘’ cycle,‘‘q’’ qx,‘‘999’’ jf_county_id,‘‘全市’’ name,
count(distinct case when a.类型=‘‘携入’’ and a.startday=‘’‘||p_day||’‘’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 日携入量,
count(distinct case when a.类型=‘‘携入’’ and a.startday=‘’‘||p_day||’‘’ and a.携出运营商=‘‘联通’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 日携入量_联通,
count(distinct case when a.类型=‘‘携入’’ and a.startday=‘’‘||p_day||’‘’ and a.携出运营商=‘‘电信’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 日携入量_电信,

count(distinct case when a.类型=‘‘携出’’ and a.startday=‘’‘||p_day||’‘’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 日携出量,
count(distinct case when a.类型=‘‘携出’’ and a.startday=‘’‘||p_day||’‘’ and a.携入运营商=‘‘联通’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 日携出量_联通,
count(distinct case when a.类型=‘‘携出’’ and a.startday=‘’‘||p_day||’‘’ and a.携入运营商=‘‘电信’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 日携出量_电信,

count(distinct case when a.类型=‘‘携入’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 月携入量,
count(distinct case when a.类型=‘‘携入’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.携出运营商=‘‘联通’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 月携入量_联通,
count(distinct case when a.类型=‘‘携入’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.携出运营商=‘‘电信’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 月携入量_电信,

count(distinct case when a.类型=‘‘携出’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 月携出量,
count(distinct case when a.类型=‘‘携出’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.携入运营商=‘‘联通’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 月携出量_联通,
count(distinct case when a.类型=‘‘携出’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.携入运营商=‘‘电信’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 月携出量_电信,

count(distinct case when a.类型=‘‘携入’’ and substr(a.startday,1,4)=‘’‘||v_yesr||’‘’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 年携入量,
count(distinct case when a.类型=‘‘携入’’ and substr(a.startday,1,4)=‘’‘||v_yesr||’‘’ and a.携出运营商=‘‘联通’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 年携入量_联通,
count(distinct case when a.类型=‘‘携入’’ and substr(a.startday,1,4)=‘’‘||v_yesr||’‘’ and a.携出运营商=‘‘电信’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 年携入量_电信,

count(distinct case when a.类型=‘‘携出’’ and substr(a.startday,1,4)=‘’‘||v_yesr||’‘’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 年携出量,
count(distinct case when a.类型=‘‘携出’’ and substr(a.startday,1,4)=‘’‘||v_yesr||’‘’ and a.携入运营商=‘‘联通’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 年携出量_联通,
count(distinct case when a.类型=‘‘携出’’ and substr(a.startday,1,4)=‘’‘||v_yesr||’‘’ and a.携入运营商=‘‘电信’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 年携出量_电信,
‘‘分割线’’ fen,-----------------------------------------------------------------------------
count(distinct case when a.类型=‘‘携入’’ and a.新网龄天数>=31 and a.startday=‘’‘||p_day||’‘’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_日携入量,
count(distinct case when a.类型=‘‘携入’’ and a.新网龄天数>=31 and a.startday=‘’‘||p_day||’‘’ and a.携出运营商=‘‘联通’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_日携入量_联通,
count(distinct case when a.类型=‘‘携入’’ and a.新网龄天数>=31 and a.startday=‘’‘||p_day||’‘’ and a.携出运营商=‘‘电信’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_日携入量_电信,

count(distinct case when a.类型=‘‘携出’’ and a.新网龄天数>=31 and a.startday=‘’‘||p_day||’‘’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_日携出量,
count(distinct case when a.类型=‘‘携出’’ and a.新网龄天数>=31 and a.startday=‘’‘||p_day||’‘’ and a.携入运营商=‘‘联通’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_日携出量_联通,
count(distinct case when a.类型=‘‘携出’’ and a.新网龄天数>=31 and a.startday=‘’‘||p_day||’‘’ and a.携入运营商=‘‘电信’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_日携出量_电信,

count(distinct case when a.类型=‘‘携入’’ and a.新网龄天数>=31 and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_月携入量,
count(distinct case when a.类型=‘‘携入’’ and a.新网龄天数>=31 and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.携出运营商=‘‘联通’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_月携入量_联通,
count(distinct case when a.类型=‘‘携入’’ and a.新网龄天数>=31 and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.携出运营商=‘‘电信’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_月携入量_电信,

count(distinct case when a.类型=‘‘携出’’ and a.新网龄天数>=31 and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_月携出量,
count(distinct case when a.类型=‘‘携出’’ and a.新网龄天数>=31 and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.携入运营商=‘‘联通’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_月携出量_联通,
count(distinct case when a.类型=‘‘携出’’ and a.新网龄天数>=31 and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.携入运营商=‘‘电信’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_月携出量_电信,

count(distinct case when a.类型=‘‘携入’’ and a.新网龄天数>=31 and substr(a.startday,1,4)=‘’‘||v_yesr||’‘’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_年携入量,
count(distinct case when a.类型=‘‘携入’’ and a.新网龄天数>=31 and substr(a.startday,1,4)=‘’‘||v_yesr||’‘’ and a.携出运营商=‘‘联通’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_年携入量_联通,
count(distinct case when a.类型=‘‘携入’’ and a.新网龄天数>=31 and substr(a.startday,1,4)=‘’‘||v_yesr||’‘’ and a.携出运营商=‘‘电信’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_年携入量_电信,

count(distinct case when a.类型=‘‘携出’’ and a.新网龄天数>=31 and substr(a.startday,1,4)=‘’‘||v_yesr||’‘’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_年携出量,
count(distinct case when a.类型=‘‘携出’’ and a.新网龄天数>=31 and substr(a.startday,1,4)=‘’‘||v_yesr||’‘’ and a.携入运营商=‘‘联通’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_年携出量_联通,
count(distinct case when a.类型=‘‘携出’’ and a.新网龄天数>=31 and substr(a.startday,1,4)=‘’‘||v_yesr||’‘’ and a.携入运营商=‘‘电信’’ then a.telnum||a.subsid||a.类型||a.携出运营商||a.携入运营商||a.starttime end) 非低网龄_年携出量_电信
from shzc.sm_gzl_gzl_hmmx_xzhma a ';
EXECUTE IMMEDIATE (SQL_STRING);

-------结果1

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xz_qxhz’),‘SHZC’);
SQL_STRING:='create table shzc.sm_gzl_gzl_hmmx_xz_qxhz as
select a.cycle,a.qx,a.jf_county_id,a.name,
a.非低网龄_日携入量,a.非低网龄_日携出量,round(a.非低网龄_日携入量/decode(a.非低网龄_日携出量,0,1,a.非低网龄_日携出量),2) 非低网龄_日入出比,
a.非低网龄_日携入量-a.非低网龄_日携出量 非低网龄_日净发展,
a.非低网龄_月携入量,a.非低网龄_月携出量,round(a.非低网龄_月携入量/decode(a.非低网龄_月携出量,0,1,a.非低网龄_月携出量),2) 非低网龄_月入出比,
a.非低网龄_月携入量-a.非低网龄_月携出量 非低网龄_月净发展,
a.日携入量_联通,a.日携出量_联通,a.日携入量_联通-a.日携出量_联通 日净发展_联通,
a.月携入量_联通,a.月携出量_联通,a.月携入量_联通-a.月携出量_联通 月净发展_联通,
a.日携入量_电信,a.日携出量_电信,a.日携入量_电信-a.日携出量_电信 日净发展_电信,
a.月携入量_电信,a.月携出量_电信,a.月携入量_电信-a.月携出量_电信 月净发展_电信,

a.日携入量,a.日携出量,round(a.日携入量/decode(a.日携出量,0,1,a.日携出量),2) 日入出比,
a.日携入量-a.日携出量 日净发展,
a.月携入量,a.月携出量,round(a.月携入量/decode(a.月携出量,0,1,a.月携出量),2) 月入出比,
a.月携入量-a.月携出量 月净发展,
a.年携入量,a.年携出量,round(a.年携入量/decode(a.年携出量,0,1,a.年携出量),2) 年入出比,
a.年携入量-a.年携出量 年净发展
from shzc.sm_gzl_gzl_hmmx_xz_hz a ';
EXECUTE IMMEDIATE (SQL_STRING);

---- 三、发展客户精准运营

–A类:dw_A_dm_user_othernet_mm

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xz_a_mx’),‘SHZC’);
SQL_STRING:='create table shzc.sm_gzl_gzl_hmmx_xz_a_mx as
select distinct a.op_time,a.product_no from zibo.DW_A_DM_USER_OTHERNET_YH_DS a
where a.op_time in (select max(a.op_time) from zibo.DW_A_DM_USER_OTHERNET_YH_DS a) ';
EXECUTE IMMEDIATE (SQL_STRING);

–B类:dw_B_broadband_other_user_mm

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xz_b_mx’),‘SHZC’);
SQL_STRING:='create table shzc.sm_gzl_gzl_hmmx_xz_b_mx as
select max(a.op_time) op_time,a.product_no from zibo.DW_B_BROADBAND_OTHER_USER_MM a
group by a.product_no ';
EXECUTE IMMEDIATE (SQL_STRING);

–C类: dw_notbroadband_user_ds

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xz_c_mx’),‘SHZC’);
SQL_STRING:='create table shzc.sm_gzl_gzl_hmmx_xz_c_mx as
select distinct a.op_time,a.user_id,a.product_no from zibo.D_NOTBROADBAND_USER_DS a
where a.op_time in (select max(a.op_time) from zibo.D_NOTBROADBAND_USER_DS a) ';
EXECUTE IMMEDIATE (SQL_STRING);

–D类:dw_d_comp_user_mm

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xz_d_mx’),‘SHZC’);
SQL_STRING:='create table shzc.sm_gzl_gzl_hmmx_xz_d_mx as
select distinct a.op_time,a.comp_product_no from zibo.D_COMP_USER_MM a
where a.op_time in (select max(a.op_time) from zibo.D_COMP_USER_MM a) ';
EXECUTE IMMEDIATE (SQL_STRING);


zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xzhm_fc’),‘SHZC’);
SQL_STRING:='create table shzc.sm_gzl_gzl_hmmx_xzhm_fc as
select distinct a.*,
nvl(case when b1.product_no is not null then 1 end,0) A类,
nvl(case when b2.product_no is not null then 1 end,0) B类,
nvl(case when b3.user_id is not null then 1 end,0) C类,
nvl(case when b4.comp_product_no is not null then 1 end,0) D类
from shzc.sm_gzl_gzl_hmmx_xzhma a,
(select * from shzc.sm_gzl_gzl_hmmx_xz_a_mx b ) b1,
(select * from shzc.sm_gzl_gzl_hmmx_xz_b_mx b ) b2,
(select * from shzc.sm_gzl_gzl_hmmx_xz_c_mx b ) b3,
(select * from shzc.sm_gzl_gzl_hmmx_xz_d_mx b ) b4
where a.telnum=b1.product_no(+)
and a.telnum=b2.product_no(+)
and a.subsid=b3.user_id(+)
and a.telnum=b4.comp_product_no(+) ';
EXECUTE IMMEDIATE (SQL_STRING);

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xzhm_fca’),‘SHZC’);
SQL_STRING:=‘create table shzc.sm_gzl_gzl_hmmx_xzhm_fca as
select ‘’’||p_day||‘’’ cycle,a.qx,a.jf_county_id,a.name,
count(distinct case when substr(a.startday,1,6) =‘’‘||v_monsrq||’‘’ then a.telnum||a.starttime||a.subsid end) 上月发展量,
count(distinct case when substr(a.startday,1,6) =‘’‘||v_monsr||’‘’ then a.telnum||a.starttime||a.subsid end) 本月发展量,
count(distinct case when substr(a.startday,1,6) =‘’‘||v_monsrq||’‘’ and a.a类+a.b类+a.c类+a.d类>0 then a.telnum||a.starttime||a.subsid end) 上月四类发展量,
count(distinct case when substr(a.startday,1,6) =‘’‘||v_monsr||’‘’ and a.a类+a.b类+a.c类+a.d类>0 then a.telnum||a.starttime||a.subsid end) 本月四类发展量,
count(distinct case when substr(a.startday,1,6) =‘’‘||v_monsrq||’‘’ and a.a类>0 then a.telnum||a.starttime||a.subsid end) 上月A类发展量,
count(distinct case when substr(a.startday,1,6) =‘’‘||v_monsr||’‘’ and a.a类>0 then a.telnum||a.starttime||a.subsid end) 本月A类发展量,
count(distinct case when substr(a.startday,1,6) =‘’‘||v_monsrq||’‘’ and a.b类>0 then a.telnum||a.starttime||a.subsid end) 上月B类发展量,
count(distinct case when substr(a.startday,1,6) =‘’‘||v_monsr||’‘’ and a.b类>0 then a.telnum||a.starttime||a.subsid end) 本月B类发展量,
count(distinct case when substr(a.startday,1,6) =‘’‘||v_monsrq||’‘’ and a.c类>0 then a.telnum||a.starttime||a.subsid end) 上月C类发展量,
count(distinct case when substr(a.startday,1,6) =‘’‘||v_monsr||’‘’ and a.c类>0 then a.telnum||a.starttime||a.subsid end) 本月C类发展量,
count(distinct case when substr(a.startday,1,6) =‘’‘||v_monsrq||’‘’ and a.d类>0 then a.telnum||a.starttime||a.subsid end) 上月D类发展量,
count(distinct case when substr(a.startday,1,6) =‘’‘||v_monsr||’‘’ and a.d类>0 then a.telnum||a.starttime||a.subsid end) 本月D类发展量
from shzc.sm_gzl_gzl_hmmx_xzhm_fc a where a.类型 =‘‘携入’’ and a.新网龄天数>=31
and to_number(substr(a.startday,7,2))<=to_number(substr(‘’‘||p_day||’‘’,7,2))
group by a.qx,a.jf_county_id,a.name
union all
select ‘’‘||p_day||’‘’ cycle,‘‘q’’ qx,‘‘999’‘jf_county_id,’‘全市’’ name,
count(distinct case when substr(a.startday,1,6) =‘’‘||v_monsrq||’‘’ then a.telnum||a.starttime||a.subsid end) 上月发展量,
count(distinct case when substr(a.startday,1,6) =‘’‘||v_monsr||’‘’ then a.telnum||a.starttime||a.subsid end) 本月发展量,
count(distinct case when substr(a.startday,1,6) =‘’‘||v_monsrq||’‘’ and a.a类+a.b类+a.c类+a.d类>0 then a.telnum||a.starttime||a.subsid end) 上月四类发展量,
count(distinct case when substr(a.startday,1,6) =‘’‘||v_monsr||’‘’ and a.a类+a.b类+a.c类+a.d类>0 then a.telnum||a.starttime||a.subsid end) 本月四类发展量,
count(distinct case when substr(a.startday,1,6) =‘’‘||v_monsrq||’‘’ and a.a类>0 then a.telnum||a.starttime||a.subsid end) 上月A类发展量,
count(distinct case when substr(a.startday,1,6) =‘’‘||v_monsr||’‘’ and a.a类>0 then a.telnum||a.starttime||a.subsid end) 本月A类发展量,
count(distinct case when substr(a.startday,1,6) =‘’‘||v_monsrq||’‘’ and a.b类>0 then a.telnum||a.starttime||a.subsid end) 上月B类发展量,
count(distinct case when substr(a.startday,1,6) =‘’‘||v_monsr||’‘’ and a.b类>0 then a.telnum||a.starttime||a.subsid end) 本月B类发展量,
count(distinct case when substr(a.startday,1,6) =‘’‘||v_monsrq||’‘’ and a.c类>0 then a.telnum||a.starttime||a.subsid end) 上月C类发展量,
count(distinct case when substr(a.startday,1,6) =‘’‘||v_monsr||’‘’ and a.c类>0 then a.telnum||a.starttime||a.subsid end) 本月C类发展量,
count(distinct case when substr(a.startday,1,6) =‘’‘||v_monsrq||’‘’ and a.d类>0 then a.telnum||a.starttime||a.subsid end) 上月D类发展量,
count(distinct case when substr(a.startday,1,6) =‘’‘||v_monsr||’‘’ and a.d类>0 then a.telnum||a.starttime||a.subsid end) 本月D类发展量
from shzc.sm_gzl_gzl_hmmx_xzhm_fc a where a.类型 =‘‘携入’’ and a.新网龄天数>=31
and to_number(substr(a.startday,7,2))<=to_number(substr(‘’‘||p_day||’‘’,7,2)) ';
EXECUTE IMMEDIATE (SQL_STRING);

—结果3

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xzhm_fcb’),‘SHZC’);
SQL_STRING:='create table shzc.sm_gzl_gzl_hmmx_xzhm_fcb as
select a.cycle,a.qx,a.jf_county_id,a.name,
a.上月发展量,a.本月发展量,
round((a.本月发展量-a.上月发展量)/decode(a.上月发展量,0,1,a.上月发展量)*100,2) 本月发展量环比,
a.上月四类发展量,round(a.上月四类发展量/decode(a.上月发展量,0,1,a.上月发展量)*100,2) 上月四类占比,
a.本月四类发展量,round(a.本月四类发展量/decode(a.本月发展量,0,1,a.本月发展量)*100,2) 本月四类占比,
round((a.本月四类发展量-a.上月四类发展量)/decode(a.上月四类发展量,0,1,a.上月四类发展量)*100,2) 本月四类发展量环比,

   a.上月a类发展量,round(a.上月a类发展量/decode(a.上月发展量,0,1,a.上月发展量)*100,2) 上月a类占比,a.本月a类发展量,round(a.本月a类发展量/decode(a.本月发展量,0,1,a.本月发展量)*100,2) 本月a类占比,round((a.本月a类发展量-a.上月a类发展量)/decode(a.上月a类发展量,0,1,a.上月a类发展量)*100,2) 本月a类发展量环比,a.上月b类发展量,round(a.上月b类发展量/decode(a.上月发展量,0,1,a.上月发展量)*100,2) 上月b类占比,a.本月b类发展量,round(a.本月b类发展量/decode(a.本月发展量,0,1,a.本月发展量)*100,2) 本月b类占比,round((a.本月b类发展量-a.上月b类发展量)/decode(a.上月b类发展量,0,1,a.上月b类发展量)*100,2) 本月b类发展量环比,a.上月c类发展量,round(a.上月c类发展量/decode(a.上月发展量,0,1,a.上月发展量)*100,2) 上月c类占比,a.本月c类发展量,round(a.本月c类发展量/decode(a.本月发展量,0,1,a.本月发展量)*100,2) 本月c类占比,round((a.本月c类发展量-a.上月c类发展量)/decode(a.上月c类发展量,0,1,a.上月c类发展量)*100,2) 本月c类发展量环比,a.上月d类发展量,round(a.上月d类发展量/decode(a.上月发展量,0,1,a.上月发展量)*100,2) 上月d类占比,a.本月d类发展量,round(a.本月d类发展量/decode(a.本月发展量,0,1,a.本月发展量)*100,2) 本月d类占比,round((a.本月d类发展量-a.上月d类发展量)/decode(a.上月d类发展量,0,1,a.上月d类发展量)*100,2) 本月d类发展量环比

from shzc.sm_gzl_gzl_hmmx_xzhm_fca a ';
EXECUTE IMMEDIATE (SQL_STRING);

-----四、发展渠道跟踪 2023-0210 写入位置

SQL_STRING:=‘insert into shzc.sm_gzl_gzl_fanghao_bd
select a.registerorgid,a.subsid,a.servnumber,a.prodid,a.prodname,a.jiazhi,a.recopid,a.oid,a.formnum,
a.recdate,a.recorgid,a.折后价值,a.是否折后48,a.是否69以上,a.等效69,a.等效48
from zhyw.shc_fanghao_’||v_monsr||’ a
where not exists (select 1 from shzc.sm_gzl_gzl_fanghao_bd b where b.subsid=a.subsid and b.oid=a.oid) ';
EXECUTE IMMEDIATE (SQL_STRING);
commit;

—select * from zhyw.hc_hangye_shangqi_operid 客户经理目标库

----2023-0209 带政企、重客、集客三类字眼归政企

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xzhm_qd’),‘SHZC’);
SQL_STRING:=‘create table shzc.sm_gzl_gzl_hmmx_xzhm_qd as
select a.*,c.recopid,d.经理类型,c.oid,c.formnum,c.recdate,
b.orgname,b.status status_qd,b.是否自办渠道,b.单位类型,b.渠道类型,b.渠道类别,b.是否核心渠道,b.是否自办营业厅,
nvl(case when d.经理类型 is not null then ‘‘政企’’
when nvl(b.orgname,’‘0’‘) like ‘’%政企%’’ then ‘‘政企’’
when nvl(b.orgname,‘‘0’’) like ‘’%重客%‘’ then ‘‘政企’’
when nvl(b.orgname,‘‘0’’) like ‘’%集客%‘’ then ‘‘政企’’
when nvl(b.orgname,‘‘0’’) like ‘’%集团客户%‘’ then ‘‘政企’’
when nvl(b.orgname,‘‘0’’) like ‘’%大客户管理%‘’ then ‘‘政企’’ end,‘‘非’’) 是否政企
from shzc.sm_gzl_gzl_hmmx_xzhma a,
zhyw.shc_organization b,
shzc.sm_gzl_gzl_fanghao_bd c,
zhyw.hc_hangye_shangqi_operid d
where a.registerorgid=b.orgid(+)
and a.subsid=c.subsid(+)
and c.recopid=d.客户经理(+)
and a.类型 =‘‘携入’’ ';
EXECUTE IMMEDIATE (SQL_STRING);

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xzhm_qda’),‘SHZC’);
SQL_STRING:=‘create table shzc.sm_gzl_gzl_hmmx_xzhm_qda as
select substr(a.startday,1,6) cycle,a.qx,a.name,a.registerorgid,a.orgname,a.是否政企,
a.是否自办渠道, 单位类型, 渠道类型, 渠道类别, 是否核心渠道, 是否自办营业厅,count(distinct a.telnum||a.starttime||a.subsid) 号码数
from shzc.sm_gzl_gzl_hmmx_xzhm_qd a
where to_number(substr(a.startday,7,2))<=to_number(substr(’‘’||p_day||‘’‘,7,2))
and substr(a.startday,1,6)>=’‘’||v_monsrq||‘’’
group by substr(a.startday,1,6),a.qx,a.name,a.registerorgid,a.orgname,a.是否政企,
a.是否自办渠道, 单位类型, 渠道类型, 渠道类别, 是否核心渠道, 是否自办营业厅 ';
EXECUTE IMMEDIATE (SQL_STRING);

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xzhm_qdb’),‘SHZC’);
SQL_STRING:=‘create table shzc.sm_gzl_gzl_hmmx_xzhm_qdb as
select a.*,nvl(case when nvl(a.是否政企,’‘0’‘)=’‘政企’’ then ‘‘政企’’
when nvl(a.orgname,‘‘0’’) like ‘’%随销%‘’ then ‘‘随销’’
when nvl(a.单位类型,‘‘0’’)=‘‘直销渠道’’ then ‘‘直销’’
when nvl(a.是否自办渠道,‘‘0’’)=‘‘自办渠道’’ then ‘‘自办’‘end,’‘代办’’) 类型
from shzc.sm_gzl_gzl_hmmx_xzhm_qda a ';
EXECUTE IMMEDIATE (SQL_STRING);

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xzhm_qdc’),‘SHZC’);
SQL_STRING:=‘create table shzc.sm_gzl_gzl_hmmx_xzhm_qdc as
select ‘’’||p_day||‘’’ cycle, a.qx,a.name,
count(case when a.cycle=‘’‘||v_monsrq||’‘’ then a.registerorgid end) 上月渠道数,
sum(nvl(case when a.cycle=‘’‘||v_monsrq||’‘‘then a.号码数 end,0)) 上月放号数,
count(case when a.cycle=’’‘||v_monsr||’‘’ then a.registerorgid end) 本月渠道数,
sum(nvl(case when a.cycle=‘’‘||v_monsr||’‘‘then a.号码数 end,0)) 本月放号数,
—自办
count(case when a.类型=’‘自办’‘and a.cycle=’’‘||v_monsrq||’‘’ then a.registerorgid end) 上月自办渠道数,
sum(nvl(case when a.类型=‘‘自办’’ and a.cycle=‘’‘||v_monsrq||’‘‘then a.号码数 end,0)) 上月自办放号数,
count(case when a.类型=’‘自办’‘and a.cycle=’’‘||v_monsr||’‘’ then a.registerorgid end) 本月自办渠道数,
sum(nvl(case when a.类型=‘‘自办’’ and a.cycle=‘’‘||v_monsr||’‘’ then a.号码数 end,0)) 本月自办放号数,
—代办
count(case when a.类型=‘‘代办’‘and a.cycle=’’‘||v_monsrq||’‘’ then a.registerorgid end) 上月代办渠道数,
sum(nvl(case when a.类型=‘‘代办’’ and a.cycle=‘’‘||v_monsrq||’‘‘then a.号码数 end,0)) 上月代办放号数,
count(case when a.类型=’‘代办’‘and a.cycle=’’‘||v_monsr||’‘’ then a.registerorgid end) 本月代办渠道数,
sum(nvl(case when a.类型=‘‘代办’’ and a.cycle=‘’‘||v_monsr||’‘’ then a.号码数 end,0)) 本月代办放号数,
—随销
count(case when a.类型=‘‘随销’‘and a.cycle=’’‘||v_monsrq||’‘’ then a.registerorgid end) 上月随销渠道数,
sum(nvl(case when a.类型=‘‘随销’’ and a.cycle=‘’‘||v_monsrq||’‘‘then a.号码数 end,0)) 上月随销放号数,
count(case when a.类型=’‘随销’‘and a.cycle=’’‘||v_monsr||’‘’ then a.registerorgid end) 本月随销渠道数,
sum(nvl(case when a.类型=‘‘随销’’ and a.cycle=‘’‘||v_monsr||’‘’ then a.号码数 end,0)) 本月随销放号数,
—直销
count(case when a.类型=‘‘直销’‘and a.cycle=’’‘||v_monsrq||’‘’ then a.registerorgid end) 上月直销渠道数,
sum(nvl(case when a.类型=‘‘直销’’ and a.cycle=‘’‘||v_monsrq||’‘‘then a.号码数 end,0)) 上月直销放号数,
count(case when a.类型=’‘直销’‘and a.cycle=’’‘||v_monsr||’‘’ then a.registerorgid end) 本月直销渠道数,
sum(nvl(case when a.类型=‘‘直销’’ and a.cycle=‘’‘||v_monsr||’‘’ then a.号码数 end,0)) 本月直销放号数,
—政企
count(case when a.类型=‘‘政企’‘and a.cycle=’’‘||v_monsrq||’‘’ then a.registerorgid end) 上月政企渠道数,
sum(nvl(case when a.类型=‘‘政企’’ and a.cycle=‘’‘||v_monsrq||’‘‘then a.号码数 end,0)) 上月政企放号数,
count(case when a.类型=’‘政企’‘and a.cycle=’’‘||v_monsr||’‘’ then a.registerorgid end) 本月政企渠道数,
sum(nvl(case when a.类型=‘‘政企’’ and a.cycle=‘’‘||v_monsr||’‘’ then a.号码数 end,0)) 本月政企放号数

from shzc.sm_gzl_gzl_hmmx_xzhm_qdb a
group by a.qx,a.name
union all
select ‘’‘||p_day||’‘’ cycle, ‘‘q’’ qx,‘‘全市’’ name,
count(case when a.cycle=‘’‘||v_monsrq||’‘’ then a.registerorgid end) 上月渠道数,
sum(nvl(case when a.cycle=‘’‘||v_monsrq||’‘‘then a.号码数 end,0)) 上月放号数,
count(case when a.cycle=’’‘||v_monsr||’‘’ then a.registerorgid end) 本月渠道数,
sum(nvl(case when a.cycle=‘’‘||v_monsr||’‘‘then a.号码数 end,0)) 本月放号数,
—自办
count(case when a.类型=’‘自办’‘and a.cycle=’’‘||v_monsrq||’‘’ then a.registerorgid end) 上月自办渠道数,
sum(nvl(case when a.类型=‘‘自办’’ and a.cycle=‘’‘||v_monsrq||’‘‘then a.号码数 end,0)) 上月自办放号数,
count(case when a.类型=’‘自办’‘and a.cycle=’’‘||v_monsr||’‘’ then a.registerorgid end) 本月自办渠道数,
sum(nvl(case when a.类型=‘‘自办’’ and a.cycle=‘’‘||v_monsr||’‘’ then a.号码数 end,0)) 本月自办放号数,
—代办
count(case when a.类型=‘‘代办’‘and a.cycle=’’‘||v_monsrq||’‘’ then a.registerorgid end) 上月代办渠道数,
sum(nvl(case when a.类型=‘‘代办’’ and a.cycle=‘’‘||v_monsrq||’‘‘then a.号码数 end,0)) 上月代办放号数,
count(case when a.类型=’‘代办’‘and a.cycle=’’‘||v_monsr||’‘’ then a.registerorgid end) 本月代办渠道数,
sum(nvl(case when a.类型=‘‘代办’’ and a.cycle=‘’‘||v_monsr||’‘’ then a.号码数 end,0)) 本月代办放号数,
—随销
count(case when a.类型=‘‘随销’‘and a.cycle=’’‘||v_monsrq||’‘’ then a.registerorgid end) 上月随销渠道数,
sum(nvl(case when a.类型=‘‘随销’’ and a.cycle=‘’‘||v_monsrq||’‘‘then a.号码数 end,0)) 上月随销放号数,
count(case when a.类型=’‘随销’‘and a.cycle=’’‘||v_monsr||’‘’ then a.registerorgid end) 本月随销渠道数,
sum(nvl(case when a.类型=‘‘随销’’ and a.cycle=‘’‘||v_monsr||’‘’ then a.号码数 end,0)) 本月随销放号数,
—直销
count(case when a.类型=‘‘直销’‘and a.cycle=’’‘||v_monsrq||’‘’ then a.registerorgid end) 上月直销渠道数,
sum(nvl(case when a.类型=‘‘直销’’ and a.cycle=‘’‘||v_monsrq||’‘‘then a.号码数 end,0)) 上月直销放号数,
count(case when a.类型=’‘直销’‘and a.cycle=’’‘||v_monsr||’‘’ then a.registerorgid end) 本月直销渠道数,
sum(nvl(case when a.类型=‘‘直销’’ and a.cycle=‘’‘||v_monsr||’‘’ then a.号码数 end,0)) 本月直销放号数,
—政企
count(case when a.类型=‘‘政企’‘and a.cycle=’’‘||v_monsrq||’‘’ then a.registerorgid end) 上月政企渠道数,
sum(nvl(case when a.类型=‘‘政企’’ and a.cycle=‘’‘||v_monsrq||’‘‘then a.号码数 end,0)) 上月政企放号数,
count(case when a.类型=’‘政企’‘and a.cycle=’’‘||v_monsr||’‘’ then a.registerorgid end) 本月政企渠道数,
sum(nvl(case when a.类型=‘‘政企’’ and a.cycle=‘’‘||v_monsr||’‘’ then a.号码数 end,0)) 本月政企放号数
from shzc.sm_gzl_gzl_hmmx_xzhm_qdb a ';
EXECUTE IMMEDIATE (SQL_STRING);

----结果4

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xzhm_qdd’),‘SHZC’);
SQL_STRING:='create table shzc.sm_gzl_gzl_hmmx_xzhm_qdd as
select a.cycle,a.qx,a.name,
a.上月放号数,
a.本月放号数,
a.上月自办放号数,
a.本月自办放号数,
round(a.上月自办放号数/decode(a.上月放号数,0,1,a.上月放号数)*100,2) 上月自办产能占比,
round(a.本月自办放号数/decode(a.本月放号数,0,1,a.本月放号数)*100,2) 本月自办产能占比,
round((a.本月自办放号数-a.上月自办放号数)/decode(a.上月自办放号数,0,1,a.上月自办放号数)*100,2) 本月自办产能月环比,
a.上月代办放号数,
a.本月代办放号数,
round(a.上月代办放号数/decode(a.上月放号数,0,1,a.上月放号数)*100,2) 上月代办产能占比,
round(a.本月代办放号数/decode(a.本月放号数,0,1,a.本月放号数)*100,2) 本月代办产能占比,
round((a.本月代办放号数-a.上月代办放号数)/decode(a.上月代办放号数,0,1,a.上月代办放号数)*100,2) 本月代办产能月环比,
a.上月随销放号数,
a.本月随销放号数,
round(a.上月随销放号数/decode(a.上月放号数,0,1,a.上月放号数)*100,2) 上月随销产能占比,
round(a.本月随销放号数/decode(a.本月放号数,0,1,a.本月放号数)*100,2) 本月随销产能占比,
round((a.本月随销放号数-a.上月随销放号数)/decode(a.上月随销放号数,0,1,a.上月随销放号数)*100,2) 本月随销产能月环比,
a.上月直销放号数,
a.本月直销放号数,
round(a.上月直销放号数/decode(a.上月放号数,0,1,a.上月放号数)*100,2) 上月直销产能占比,
round(a.本月直销放号数/decode(a.本月放号数,0,1,a.本月放号数)*100,2) 本月直销产能占比,
round((a.本月直销放号数-a.上月直销放号数)/decode(a.上月直销放号数,0,1,a.上月直销放号数)*100,2) 本月直销产能月环比,
a.上月政企放号数,
a.本月政企放号数,
round(a.上月政企放号数/decode(a.上月放号数,0,1,a.上月放号数)*100,2) 上月政企产能占比,
round(a.本月政企放号数/decode(a.本月放号数,0,1,a.本月放号数)*100,2) 本月政企产能占比,
round((a.本月政企放号数-a.上月政企放号数)/decode(a.上月政企放号数,0,1,a.上月政企放号数)*100,2) 本月政企产能月环比
from shzc.sm_gzl_gzl_hmmx_xzhm_qdc a ';
EXECUTE IMMEDIATE (SQL_STRING);

-----渠道 月破零率
—select * from zhyw.hc_hangye_shangqi_operid 客户经理目标库

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xzhm_pl’),‘SHZC’);
SQL_STRING:='create table shzc.sm_gzl_gzl_hmmx_xzhm_pl as
select a.*,b.orgid from zhyw.hc_hangye_shangqi_operid a,
tbcs.operator@bcv b
where a.客户经理=b.operid ';
EXECUTE IMMEDIATE (SQL_STRING);

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xzhm_pla’),‘SHZC’);
SQL_STRING:=‘create table shzc.sm_gzl_gzl_hmmx_xzhm_pla as
select ‘’’||v_monsrq||‘’’ cycle,a.orgid,a.orgname,a.status,a.是否自办渠道,a.单位类型,a.渠道类型,a.渠道类别,
nvl(case when t.orgid is not null then ‘‘政企’’
when nvl(a.orgname,‘‘0’’) like ‘’%政企%‘’ then ‘‘政企’’
when nvl(a.orgname,‘‘0’’) like ‘’%重客%‘’ then ‘‘政企’’
when nvl(a.orgname,‘‘0’’) like ‘’%集客%‘’ then ‘‘政企’’
when nvl(a.orgname,‘‘0’’) like ‘’%集团客户%‘’ then ‘‘政企’’
when nvl(a.orgname,‘‘0’’) like ‘’%大客户管理%‘’ then ‘‘政企’’ end,‘‘非’’) 是否政企,
nvl(case when nvl(case when t.orgid is not null then ‘‘政企’’
when nvl(a.orgname,‘‘0’’) like ‘’%政企%‘’ then ‘‘政企’’
when nvl(a.orgname,‘‘0’’) like ‘’%重客%‘’ then ‘‘政企’’
when nvl(a.orgname,‘‘0’’) like ‘’%集客%‘’ then ‘‘政企’’
when nvl(a.orgname,‘‘0’’) like ‘’%集团客户%‘’ then ‘‘政企’’
when nvl(a.orgname,‘‘0’’) like ‘’%大客户管理%‘’ then ‘‘政企’’ end,‘‘非’’)=‘‘政企’’ then ‘‘政企’’
when nvl(a.orgname,‘‘0’’) like ‘’%随销%‘’ then ‘‘随销’’
when nvl(a.单位类型,‘‘0’’)=‘‘直销渠道’’ then ‘‘直销’’
when nvl(a.是否自办渠道,‘‘0’’)=‘‘自办渠道’’ then ‘‘自办’’ end,‘‘代办’’) 类型
from zhyw.shc_organization_‘||v_monsrq||’ a,
(select distinct t.orgid from shzc.sm_gzl_gzl_hmmx_xzhm_pl t ) t
where a.status=‘‘1’’
and a.orgid=t.orgid(+)
union all
select ‘’‘||v_monsr||’‘’ cycle,a.orgid,a.orgname,a.status,a.是否自办渠道,a.单位类型,a.渠道类型,a.渠道类别,
nvl(case when t.orgid is not null then ‘‘政企’’
when nvl(a.orgname,‘‘0’’) like ‘’%政企%‘’ then ‘‘政企’’
when nvl(a.orgname,‘‘0’’) like ‘’%重客%‘’ then ‘‘政企’’
when nvl(a.orgname,‘‘0’’) like ‘’%集客%‘’ then ‘‘政企’’
when nvl(a.orgname,‘‘0’’) like ‘’%集团客户%‘’ then ‘‘政企’’
when nvl(a.orgname,‘‘0’’) like ‘’%大客户管理%‘’ then ‘‘政企’’ end,‘‘非’’) 是否政企,
nvl(case when nvl(case when t.orgid is not null then ‘‘政企’’
when nvl(a.orgname,‘‘0’’) like ‘’%政企%‘’ then ‘‘政企’’
when nvl(a.orgname,‘‘0’’) like ‘’%重客%‘’ then ‘‘政企’’
when nvl(a.orgname,‘‘0’’) like ‘’%集客%‘’ then ‘‘政企’’
when nvl(a.orgname,‘‘0’’) like ‘’%集团客户%‘’ then ‘‘政企’’
when nvl(a.orgname,‘‘0’’) like ‘’%大客户管理%‘’ then ‘‘政企’’ end,‘‘非’’)=‘‘政企’’ then ‘‘政企’’
when nvl(a.orgname,‘‘0’’) like ‘’%随销%‘’ then ‘‘随销’’
when nvl(a.单位类型,‘‘0’’)=‘‘直销渠道’’ then ‘‘直销’’
when nvl(a.是否自办渠道,‘‘0’’)=‘‘自办渠道’’ then ‘‘自办’’ end,‘‘代办’’) 类型
from zhyw.shc_organization_‘||v_monsr||’ a,
(select distinct t.orgid from shzc.sm_gzl_gzl_hmmx_xzhm_pl t ) t
where a.status=‘‘1’’
and a.orgid=t.orgid(+) ';
EXECUTE IMMEDIATE (SQL_STRING);

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xzhm_plaa’),‘SHZC’);
SQL_STRING:=‘create table shzc.sm_gzl_gzl_hmmx_xzhm_plaa as
select a.*,nvl(case when nvl(substr(a.orgid,8,1),’‘0’‘) not in (select t.county_id from zhyw.rpt_county t
where t.county_id not in (’‘0’‘,’‘A’‘,’‘zbtyqd’')) then ‘‘x’’ end,substr(a.orgid,8,1)) qx
from shzc.sm_gzl_gzl_hmmx_xzhm_pla a ';
EXECUTE IMMEDIATE (SQL_STRING);

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xzhm_plab’),‘SHZC’);
SQL_STRING:=‘create table shzc.sm_gzl_gzl_hmmx_xzhm_plab as
select a.*,nvl(t.jf_county_id,’‘1008’‘) jf_county_id,nvl(t.name,’‘线上’') name
from shzc.sm_gzl_gzl_hmmx_xzhm_plaa a,
zhyw.rpt_county t
where a.qx=t.county_id(+) ';
EXECUTE IMMEDIATE (SQL_STRING);

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xzhm_plb’),‘SHZC’);
SQL_STRING:=‘create table shzc.sm_gzl_gzl_hmmx_xzhm_plb as
select a.cycle,a.qx,a.jf_county_id,a.name,a.类型,count(distinct a.orgid) orgids
from shzc.sm_gzl_gzl_hmmx_xzhm_plab a
where a.orgid in (select b.orgid from tbcs.operator@bcv b where STATUS=1 and ORGID like ‘‘SD.LC.%’’ group by b.orgid)
group by a.cycle,a.qx,a.jf_county_id,a.name,a.类型
union all
select a.cycle,’‘q’’ qx,'‘999’‘jf_county_id,’‘全市’'name,a.类型,count(distinct a.orgid) orgids
from shzc.sm_gzl_gzl_hmmx_xzhm_plab a
where a.orgid in (select b.orgid from tbcs.operator@bcv b where STATUS=1 and ORGID like ‘‘SD.LC.%’’ group by b.orgid)
group by a.cycle,a.类型 ';
EXECUTE IMMEDIATE (SQL_STRING);

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xzhm_plc’),‘SHZC’);
SQL_STRING:=‘create table shzc.sm_gzl_gzl_hmmx_xzhm_plc as
select a.cycle,a.qx,a.jf_county_id,a.name,sum(a.orgids) orgids,
max(nvl(case when a.类型=’‘自办’‘then a.orgids end,0)) 自办,
max(nvl(case when a.类型=’‘代办’‘then a.orgids end,0)) 代办,
max(nvl(case when a.类型=’‘随销’‘then a.orgids end,0)) 随销,
max(nvl(case when a.类型=’‘直销’‘then a.orgids end,0)) 直销,
max(nvl(case when a.类型=’‘政企’'then a.orgids end,0)) 政企
from shzc.sm_gzl_gzl_hmmx_xzhm_plb a
group by a.cycle,a.qx,a.jf_county_id,a.name ';
EXECUTE IMMEDIATE (SQL_STRING);

----结果5

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xzhm_pld’),‘SHZC’);
SQL_STRING:='create table shzc.sm_gzl_gzl_hmmx_xzhm_pld as
select a.cycle,a.qx,a.name,
b1.orgids 上月总渠道数,a.上月渠道数,round(a.上月渠道数/decode(b1.orgids,0,1,b1.orgids)*100,2) 上月发展渠道占比,
b2.orgids 本月总渠道数,a.本月渠道数,round(a.本月渠道数/decode(b2.orgids,0,1,b2.orgids)*100,2) 本月发展渠道占比,

b1.自办 上月自办总渠道数,a.上月自办渠道数,round(a.上月自办渠道数/decode(b1.自办,0,1,b1.自办)*100,2) 上月自办发展渠道占比,
b2.自办 本月自办总渠道数,a.本月自办渠道数,round(a.本月自办渠道数/decode(b2.自办,0,1,b2.自办)*100,2) 本月自办发展渠道占比,

b1.代办 上月代办总渠道数,a.上月代办渠道数,round(a.上月代办渠道数/decode(b1.代办,0,1,b1.代办)*100,2) 上月代办发展渠道占比,
b2.代办 本月代办总渠道数,a.本月代办渠道数,round(a.本月代办渠道数/decode(b2.代办,0,1,b2.代办)*100,2) 本月代办发展渠道占比,

b1.随销 上月随销总渠道数,a.上月随销渠道数,round(a.上月随销渠道数/decode(b1.随销,0,1,b1.随销)*100,2) 上月随销发展渠道占比,
b2.随销 本月随销总渠道数,a.本月随销渠道数,round(a.本月随销渠道数/decode(b2.随销,0,1,b2.随销)*100,2) 本月随销发展渠道占比,

b1.直销 上月直销总渠道数,a.上月直销渠道数,round(a.上月直销渠道数/decode(b1.直销,0,1,b1.直销)*100,2) 上月直销发展渠道占比,
b2.直销 本月直销总渠道数,a.本月直销渠道数,round(a.本月直销渠道数/decode(b2.直销,0,1,b2.直销)*100,2) 本月直销发展渠道占比,

b1.政企 上月政企总渠道数,a.上月政企渠道数,round(a.上月政企渠道数/decode(b1.政企,0,1,b1.政企)*100,2) 上月政企发展渠道占比,
b2.政企 本月政企总渠道数,a.本月政企渠道数,round(a.本月政企渠道数/decode(b2.政企,0,1,b2.政企)*100,2) 本月政企发展渠道占比
from shzc.sm_gzl_gzl_hmmx_xzhm_qdc a,
(select * from shzc.sm_gzl_gzl_hmmx_xzhm_plc b where b.cycle=‘’‘||v_monsrq||’‘’) b1,
(select * from shzc.sm_gzl_gzl_hmmx_xzhm_plc b where b.cycle=‘’‘||v_monsr||’‘’) b2
where a.qx=b1.qx(+)
and a.qx=b2.qx(+) ';
EXECUTE IMMEDIATE (SQL_STRING);

—六、运营健康度
—发展客户 ARPU 指 12 月发展客户在 1 月实际收入,流失客户 Arpu 指 2 月流失客户在 1 月实际收入;
—发展低网龄指发展时间距离首次过网时间≤ 30 天,流失低网龄指流失时间距离开户时间≤30 天。
—ABC1 类政企客户发展口径为近 30 天内发展客户中在本月维护为 ABC1 集团成员的客户

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xzhm_yy’),‘SHZC’);
SQL_STRING:=‘create table shzc.sm_gzl_gzl_hmmx_xzhm_yy as
select a.*,
nvl(case when a.类型=’‘携入’’ and substr(a.startday,1,6)=‘’‘||v_monsrq3||’‘’ then ‘‘上月发展’’
when a.类型=‘‘携出’’ and substr(a.startday,1,6)=‘’‘||v_monsrq||’‘’ then ‘‘上月流失’’
when a.类型=‘‘携入’’ and substr(a.startday,1,6)=‘’‘||v_monsrq2||’‘’ then ‘‘本月发展’’
when a.类型=‘‘携出’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ then ‘‘本月流失’’ end,‘‘非’’) 发展流失,

nvl(case when a.类型=‘‘携入’’ and substr(a.startday,1,6)=‘’‘||v_monsrq||’‘’ and a.新网龄天数<31 then ‘‘上月发展低网龄’’
when a.类型=‘‘携出’’ and substr(a.startday,1,6)=‘’‘||v_monsrq||’‘’ and a.新网龄天数<31 then ‘‘上月流失低网龄’’
when a.类型=‘‘携入’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.新网龄天数<31 then ‘‘本月发展低网龄’’
when a.类型=‘‘携出’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.新网龄天数<31 then ‘‘本月流失低网龄’’ end,‘‘非’’) 低网龄,
nvl(case when a.集团类型结果 in (‘‘A’’,‘‘B’’,‘‘C1’’) then ‘‘1’’ when a.集团类型结果 in (‘‘C2’’,‘‘D’’) then ‘‘2’’ end,‘‘0’’) 集团划分
from shzc.sm_gzl_gzl_hmmx_xzhma a ';
EXECUTE IMMEDIATE (SQL_STRING);

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xzhm_yya’),‘SHZC’);
SQL_STRING:=‘create table shzc.sm_gzl_gzl_hmmx_xzhm_yya as
select a.qx,a.jf_county_id,a.name,
sum(nvl(case when a.发展流失=’‘上月发展’’ then a.arpu_sy end,0)) 上月发展arpu,
count(case when a.发展流失=‘‘上月发展’’ then a.telnum||a.starttime||a.subsid end) 上月发展用户,
sum(nvl(case when a.发展流失=‘‘本月发展’’ then a.arpu end,0)) 本月发展arpu,
count(case when a.发展流失=‘‘本月发展’’ then a.telnum||a.starttime||a.subsid end) 本月发展用户,

sum(nvl(case when a.发展流失=‘‘上月流失’’ then a.arpu_sy end,0)) 上月流失arpu,
count(case when a.发展流失=‘‘上月流失’’ then a.telnum||a.starttime||a.subsid end) 上月流失用户,
sum(nvl(case when a.发展流失=‘‘本月流失’’ then a.arpu end,0)) 本月流失arpu,
count(case when a.发展流失=‘‘本月流失’’ then a.telnum||a.starttime||a.subsid end) 本月流失用户,

count(case when a.类型=‘‘携入’’ and substr(a.startday,1,6)=‘’‘||v_monsrq||’‘’ and a.startday<=‘’‘||S_DAY||’‘’ then a.telnum||a.starttime||a.subsid end) 上月同期发展用户,
count(case when a.类型=‘‘携入’’ and a.低网龄=‘‘上月发展低网龄’’ and a.startday<=‘’‘||S_DAY||’‘’ then a.telnum||a.starttime||a.subsid end) 上月发展低网龄,
count(case when a.类型=‘‘携入’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.startday<=‘’‘||p_day||’‘’ then a.telnum||a.starttime||a.subsid end) 本月同期发展用户,
count(case when a.类型=‘‘携入’’ and a.低网龄=‘‘本月发展低网龄’’ and a.startday<=‘’‘||p_day||’‘’ then a.telnum||a.starttime||a.subsid end) 本月发展低网龄,

count(case when a.类型=‘‘携出’’ and substr(a.startday,1,6)=‘’‘||v_monsrq||’‘’ and a.startday<=‘’‘||S_DAY||’‘’ then a.telnum||a.starttime||a.subsid end) 上月同期流失用户,
count(case when a.类型=‘‘携出’’ and a.低网龄=‘‘上月流失低网龄’’ and a.startday<=‘’‘||S_DAY||’‘’ then a.telnum||a.starttime||a.subsid end) 上月流失低网龄,
count(case when a.类型=‘‘携出’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.startday<=‘’‘||p_day||’‘’ then a.telnum||a.starttime||a.subsid end) 本月同期流失用户,
count(case when a.类型=‘‘携出’’ and a.低网龄=‘‘本月流失低网龄’’ and a.startday<=‘’‘||p_day||’‘’ then a.telnum||a.starttime||a.subsid end) 本月流失低网龄,

count(case when a.类型=‘‘携入’’ and a.startday=‘’‘||S_DAY||’‘’ and a.集团划分=‘‘1’’ then a.telnum||a.starttime||a.subsid end) 上月日发展abc1用户,
count(case when a.类型=‘‘携入’’ and substr(a.startday,1,6)=‘’‘||v_monsrq||’‘’ and a.startday<=‘’‘||S_DAY||’‘’ and a.集团划分=‘‘1’’ then a.telnum||a.starttime||a.subsid end) 上月发展abc1用户,
count(case when a.类型=‘‘携入’’ and a.startday=‘’‘||p_day||’‘’ and a.集团划分=‘‘1’’ then a.telnum||a.starttime||a.subsid end) 本月日发展abc1用户,
count(case when a.类型=‘‘携入’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.startday<=‘’‘||p_day||’‘’ and a.集团划分=‘‘1’’ then a.telnum||a.starttime||a.subsid end) 本月发展abc1用户,

count(case when a.类型=‘‘携出’’ and a.startday=‘’‘||S_DAY||’‘’ and a.集团划分=‘‘1’’ then a.telnum||a.starttime||a.subsid end) 上月日流失abc1用户,
count(case when a.类型=‘‘携出’’ and substr(a.startday,1,6)=‘’‘||v_monsrq||’‘’ and a.startday<=‘’‘||S_DAY||’‘’ and a.集团划分=‘‘1’’ then a.telnum||a.starttime||a.subsid end) 上月流失abc1用户,
count(case when a.类型=‘‘携出’’ and a.startday=‘’‘||p_day||’‘’ and a.集团划分=‘‘1’’ then a.telnum||a.starttime||a.subsid end) 本月日流失abc1用户,
count(case when a.类型=‘‘携出’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.startday<=‘’‘||p_day||’‘’ and a.集团划分=‘‘1’’ then a.telnum||a.starttime||a.subsid end) 本月流失abc1用户,

count(case when a.类型=‘‘携入’’ and a.startday=‘’‘||S_DAY||’‘’ and a.集团划分=‘‘2’’ then a.telnum||a.starttime||a.subsid end) 上月日发展c2d用户,
count(case when a.类型=‘‘携入’’ and substr(a.startday,1,6)=‘’‘||v_monsrq||’‘’ and a.startday<=‘’‘||S_DAY||’‘’ and a.集团划分=‘‘2’’ then a.telnum||a.starttime||a.subsid end) 上月发展c2d用户,
count(case when a.类型=‘‘携入’’ and a.startday=‘’‘||p_day||’‘’ and a.集团划分=‘‘2’’ then a.telnum||a.starttime||a.subsid end) 本月日发展c2d用户,
count(case when a.类型=‘‘携入’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.startday<=‘’‘||p_day||’‘’ and a.集团划分=‘‘2’’ then a.telnum||a.starttime||a.subsid end) 本月发展c2d用户,

count(case when a.类型=‘‘携出’’ and a.startday=‘’‘||S_DAY||’‘’ and a.集团划分=‘‘2’’ then a.telnum||a.starttime||a.subsid end) 上月日流失c2d用户,
count(case when a.类型=‘‘携出’’ and substr(a.startday,1,6)=‘’‘||v_monsrq||’‘’ and a.startday<=‘’‘||S_DAY||’‘’ and a.集团划分=‘‘2’’ then a.telnum||a.starttime||a.subsid end) 上月流失c2d用户,
count(case when a.类型=‘‘携出’’ and a.startday=‘’‘||p_day||’‘’ and a.集团划分=‘‘2’’ then a.telnum||a.starttime||a.subsid end) 本月日流失c2d用户,
count(case when a.类型=‘‘携出’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.startday<=‘’‘||p_day||’‘’ and a.集团划分=‘‘2’’ then a.telnum||a.starttime||a.subsid end) 本月流失c2d用户

from shzc.sm_gzl_gzl_hmmx_xzhm_yy a
group by a.qx,a.jf_county_id,a.name
union all
select ‘‘q’‘qx,’‘999’‘jf_county_id,’‘全市’‘name,
sum(nvl(case when a.发展流失=’‘上月发展’’ then a.arpu_sy end,0)) 上月发展arpu,
count(case when a.发展流失=‘‘上月发展’’ then a.telnum||a.starttime||a.subsid end) 上月发展用户,
sum(nvl(case when a.发展流失=‘‘本月发展’’ then a.arpu end,0)) 本月发展arpu,
count(case when a.发展流失=‘‘本月发展’’ then a.telnum||a.starttime||a.subsid end) 本月发展用户,

sum(nvl(case when a.发展流失=‘‘上月流失’’ then a.arpu_sy end,0)) 上月流失arpu,
count(case when a.发展流失=‘‘上月流失’’ then a.telnum||a.starttime||a.subsid end) 上月流失用户,
sum(nvl(case when a.发展流失=‘‘本月流失’’ then a.arpu end,0)) 本月流失arpu,
count(case when a.发展流失=‘‘本月流失’’ then a.telnum||a.starttime||a.subsid end) 本月流失用户,

count(case when a.类型=‘‘携入’’ and substr(a.startday,1,6)=‘’‘||v_monsrq||’‘’ and a.startday<=‘’‘||S_DAY||’‘’ then a.telnum||a.starttime||a.subsid end) 上月同期发展用户,
count(case when a.类型=‘‘携入’’ and a.低网龄=‘‘上月发展低网龄’’ and a.startday<=‘’‘||S_DAY||’‘’ then a.telnum||a.starttime||a.subsid end) 上月发展低网龄,
count(case when a.类型=‘‘携入’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.startday<=‘’‘||p_day||’‘’ then a.telnum||a.starttime||a.subsid end) 本月同期发展用户,
count(case when a.类型=‘‘携入’’ and a.低网龄=‘‘本月发展低网龄’’ and a.startday<=‘’‘||p_day||’‘’ then a.telnum||a.starttime||a.subsid end) 本月发展低网龄,

count(case when a.类型=‘‘携出’’ and substr(a.startday,1,6)=‘’‘||v_monsrq||’‘’ and a.startday<=‘’‘||S_DAY||’‘’ then a.telnum||a.starttime||a.subsid end) 上月同期流失用户,
count(case when a.类型=‘‘携出’’ and a.低网龄=‘‘上月流失低网龄’’ and a.startday<=‘’‘||S_DAY||’‘’ then a.telnum||a.starttime||a.subsid end) 上月流失低网龄,
count(case when a.类型=‘‘携出’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.startday<=‘’‘||p_day||’‘’ then a.telnum||a.starttime||a.subsid end) 本月同期流失用户,
count(case when a.类型=‘‘携出’’ and a.低网龄=‘‘本月流失低网龄’’ and a.startday<=‘’‘||p_day||’‘’ then a.telnum||a.starttime||a.subsid end) 本月流失低网龄,

count(case when a.类型=‘‘携入’’ and a.startday=‘’‘||S_DAY||’‘’ and a.集团划分=‘‘1’’ then a.telnum||a.starttime||a.subsid end) 上月日发展abc1用户,
count(case when a.类型=‘‘携入’’ and substr(a.startday,1,6)=‘’‘||v_monsrq||’‘’ and a.startday<=‘’‘||S_DAY||’‘’ and a.集团划分=‘‘1’’ then a.telnum||a.starttime||a.subsid end) 上月发展abc1用户,
count(case when a.类型=‘‘携入’’ and a.startday=‘’‘||p_day||’‘’ and a.集团划分=‘‘1’’ then a.telnum||a.starttime||a.subsid end) 本月日发展abc1用户,
count(case when a.类型=‘‘携入’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.startday<=‘’‘||p_day||’‘’ and a.集团划分=‘‘1’’ then a.telnum||a.starttime||a.subsid end) 本月发展abc1用户,

count(case when a.类型=‘‘携出’’ and a.startday=‘’‘||S_DAY||’‘’ and a.集团划分=‘‘1’’ then a.telnum||a.starttime||a.subsid end) 上月日流失abc1用户,
count(case when a.类型=‘‘携出’’ and substr(a.startday,1,6)=‘’‘||v_monsrq||’‘’ and a.startday<=‘’‘||S_DAY||’‘’ and a.集团划分=‘‘1’’ then a.telnum||a.starttime||a.subsid end) 上月流失abc1用户,
count(case when a.类型=‘‘携出’’ and a.startday=‘’‘||p_day||’‘’ and a.集团划分=‘‘1’’ then a.telnum||a.starttime||a.subsid end) 本月日流失abc1用户,
count(case when a.类型=‘‘携出’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.startday<=‘’‘||p_day||’‘’ and a.集团划分=‘‘1’’ then a.telnum||a.starttime||a.subsid end) 本月流失abc1用户,

count(case when a.类型=‘‘携入’’ and a.startday=‘’‘||S_DAY||’‘’ and a.集团划分=‘‘2’’ then a.telnum||a.starttime||a.subsid end) 上月日发展c2d用户,
count(case when a.类型=‘‘携入’’ and substr(a.startday,1,6)=‘’‘||v_monsrq||’‘’ and a.startday<=‘’‘||S_DAY||’‘’ and a.集团划分=‘‘2’’ then a.telnum||a.starttime||a.subsid end) 上月发展c2d用户,
count(case when a.类型=‘‘携入’’ and a.startday=‘’‘||p_day||’‘’ and a.集团划分=‘‘2’’ then a.telnum||a.starttime||a.subsid end) 本月日发展c2d用户,
count(case when a.类型=‘‘携入’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.startday<=‘’‘||p_day||’‘’ and a.集团划分=‘‘2’’ then a.telnum||a.starttime||a.subsid end) 本月发展c2d用户,

count(case when a.类型=‘‘携出’’ and a.startday=‘’‘||S_DAY||’‘’ and a.集团划分=‘‘2’’ then a.telnum||a.starttime||a.subsid end) 上月日流失c2d用户,
count(case when a.类型=‘‘携出’’ and substr(a.startday,1,6)=‘’‘||v_monsrq||’‘’ and a.startday<=‘’‘||S_DAY||’‘’ and a.集团划分=‘‘2’’ then a.telnum||a.starttime||a.subsid end) 上月流失c2d用户,
count(case when a.类型=‘‘携出’’ and a.startday=‘’‘||p_day||’‘’ and a.集团划分=‘‘2’’ then a.telnum||a.starttime||a.subsid end) 本月日流失c2d用户,
count(case when a.类型=‘‘携出’’ and substr(a.startday,1,6)=‘’‘||v_monsr||’‘’ and a.startday<=‘’‘||p_day||’‘’ and a.集团划分=‘‘2’’ then a.telnum||a.starttime||a.subsid end) 本月流失c2d用户

from shzc.sm_gzl_gzl_hmmx_xzhm_yy a ';
EXECUTE IMMEDIATE (SQL_STRING);

----结果6

zhyw.shc_drop_retable(upper(‘sm_gzl_gzl_hmmx_xzhm_yyb’),‘SHZC’);
SQL_STRING:=‘create table shzc.sm_gzl_gzl_hmmx_xzhm_yyb as
select ‘’’||p_day||‘’’ cycle,a.qx,a.jf_county_id,a.name,
a.上月发展arpu,a.上月发展用户,round(a.上月发展arpu/decode(a.上月发展用户,0,1,a.上月发展用户),2) 上月发展人均arpu,
a.本月发展arpu,a.本月发展用户,round(a.本月发展arpu/decode(a.本月发展用户,0,1,a.本月发展用户),2) 本月发展人均arpu,
a.上月流失arpu,a.上月流失用户,round(a.上月流失arpu/decode(a.上月流失用户,0,1,a.上月流失用户),2) 上月流失人均arpu,
a.本月流失arpu,a.本月流失用户,round(a.本月流失arpu/decode(a.本月流失用户,0,1,a.本月流失用户),2) 本月流失人均arpu,
a.上月同期发展用户,a.上月发展低网龄,round(a.上月发展低网龄/decode(a.上月同期发展用户,0,1,a.上月同期发展用户)*100,2) 上月发展低网龄占比,
a.本月同期发展用户,a.本月发展低网龄,round(a.本月发展低网龄/decode(a.本月同期发展用户,0,1,a.本月同期发展用户)*100,2) 本月发展低网龄占比,
a.上月同期流失用户,a.上月流失低网龄,round(a.上月流失低网龄/decode(a.上月同期流失用户,0,1,a.上月同期流失用户)*100,2) 上月流失低网龄占比,
a.本月同期流失用户,a.本月流失低网龄,round(a.本月流失低网龄/decode(a.本月同期流失用户,0,1,a.本月同期流失用户)*100,2) 本月流失低网龄占比,
a.上月日发展abc1用户,
a.上月发展abc1用户,
a.本月日发展abc1用户,
a.本月发展abc1用户,
a.上月日流失abc1用户,
a.上月流失abc1用户,
a.本月日流失abc1用户,
a.本月流失abc1用户,
a.上月日发展c2d用户,
a.上月发展c2d用户,
a.本月日发展c2d用户,
a.本月发展c2d用户,
a.上月日流失c2d用户,
a.上月流失c2d用户,
a.本月日流失c2d用户,
a.本月流失c2d用户,

   a.本月日发展abc1用户-a.本月日流失abc1用户 本月日净发展abc1用户,a.本月发展abc1用户-a.本月流失abc1用户 本月净发展abc1用户,a.本月日发展c2d用户-a.本月日流失c2d用户 本月日净发展c2d用户,a.本月发展c2d用户-a.本月流失c2d用户 本月净发展c2d用户

from shzc.sm_gzl_gzl_hmmx_xzhm_yya a ';
EXECUTE IMMEDIATE (SQL_STRING);

—结果表
–select * from shzc.sm_gzl_gzl_hmmx_xz_qxhz;
–select * from shzc.sm_gzl_gzl_hmmx_xzhm_fcb;
–select * from shzc.sm_gzl_gzl_hmmx_xzhm_qdd;
–select * from shzc.sm_gzl_gzl_hmmx_xzhm_pld;
–select * from shzc.sm_gzl_gzl_hmmx_xzhm_yyb;

相关文章:

20230215_数据库过程_高质量发展

高质量发展 —一、运营结果 SQL_STRING:‘delete shzc.np_rec_lnpdb a where exists (select * from tbcs.v_np_rec_lnpdbbcv t where a.telnumt.telnum and a.outcarriert.OUTCARRIER and a.incarriert.INCARRIER and a.owncarriert.OWNCARRIER and a.starttimet.STARTTIME …...

【百度 JavaScript API v3.0】LocalSearch 位置检索、Autocomplete 结果提示

地名检索移动到指定坐标 需求 在输入框中搜索&#xff0c;在下拉列表中浮动&#xff0c;右侧出现高亮的列表集。选中之后移动到指定坐标。 技术点 官网地址&#xff1a; JavaScript API - 快速入门 | 百度地图API SDK 开发文档&#xff1a;百度地图JSAPI 3.0类参考 实现 …...

运用Facebook投放,如何制定有效的竞价策略?

广告投放中&#xff0c;我们经常会遇到一个问题&#xff0c;就是不知道什么样的广告适合自己的业务。其实&#xff0c;最简单的方法就是根据我们业务本身进行定位并进行投放。当你了解了广告主所处行业及目标受众后&#xff0c;接下来会针对目标市场进行搜索和定位&#xff08;…...

大数据框架之Hadoop:HDFS(五)NameNode和SecondaryNameNode(面试开发重点)

5.1NN和2NN工作机制 5.1.1思考&#xff1a;NameNode中的元数据是存储在哪里的&#xff1f; 首先&#xff0c;我们做个假设&#xff0c;如果存储在NameNode节点的磁盘中&#xff0c;因为经常需要进行随机访问&#xff0c;还有响应客户请求&#xff0c;必然是效率过低。因此&am…...

计算机网络 - 1. 体系结构

目录概念、功能、组成、分类概念功能组成分类分层结构概念总结OSI 七层模型应用层表示层会话层传输层网络层数据链路层物理层TCP/IP 四层模型OSI 与 TCP/IP 相同点OSI 与 TCP/IP 不同点为什么 TCP/IP 去除了表示层和会话层五层参考模型概念、功能、组成、分类 概念 &#x1f…...

银行业上云进行时,OLAP 云服务如何解决传统数仓之痛?

本文节选自《中国金融科技发展概览&#xff1a;创新与应用前沿》&#xff0c;从某国有大行构建大数据云平台的实践出发&#xff0c;解读了 OLAP 云服务如何助力银行实现技术平台化、组件化和云服务化&#xff0c;降低技术应用门槛&#xff0c;赋能业务创新。此外&#xff0c;本…...

特定领域知识图谱融合方案:文本匹配算法之预训练Simbert、ERNIE-Gram单塔模型等诸多模型【三】

特定领域知识图谱融合方案:文本匹配算法之预训练模型SimBert、ERNIE-Gram 文本匹配任务在自然语言处理中是非常重要的基础任务之一,一般研究两段文本之间的关系。有很多应用场景;如信息检索、问答系统、智能对话、文本鉴别、智能推荐、文本数据去重、文本相似度计算、自然语…...

【2023最新教程】从0到1开发自动化测试框架(0基础也能看懂)

一、序言 随着项目版本的快速迭代、APP测试有以下几个特点&#xff1a; 首先&#xff0c;功能点多且细&#xff0c;测试工作量大&#xff0c;容易遗漏&#xff1b;其次&#xff0c;代码模块常改动&#xff0c;回归测试很频繁&#xff0c;测试重复低效&#xff1b;最后&#x…...

linux备份命令小记 —— 筑梦之路

Linux dump命令用于备份文件系统。 dump为备份工具程序&#xff0c;可将目录或整个文件系统备份至指定的设备&#xff0c;或备份成一个大文件。 dump命令只可以备份ext2/3/4格式的文件系统&#xff0c; centos7默认未安装dump命令&#xff0c;可以使用yum install -y dump安…...

vue项目(vue-cli)配置环境变量和打包时区分开发、测试、生产环境

1.打包时区分不同环境在自定义配置Vue-cli 的过程中&#xff0c;想分别通过.env.development .env.test .env.production 来代表开发、测试、生产环境。NODE_ENVdevelopment NODE_ENVtest NODE_ENVproduction本来想使用上面三种配置来区分三个环境&#xff0c;但是发现使用test…...

Python 命名规范

Python 命名规范 基本规范 类型公有内部备注Packagepackage_namenone全小写下划线式驼峰Modulemodule_name_module_name全小写下划线式驼峰ClassClassName_ClassName首字母大写式驼峰Methodmethod_nameprotected: _method_name private: __method_name全小写下划线式驼峰Exce…...

操作系统——2.操作系统的特征

这篇文章&#xff0c;我们来讲一讲操作系统的特征 目录 1.概述 2.并发 2.1并发概念 2.1.1操作系统的并发性 3.共享 3.1共享的概念 3.2共享的方式 4.并发和共享的关系 5.虚拟 5.1虚拟的概念 5.2虚拟小结 6.异步 6.1异步概念 7.小结 1.概述 上一篇文章&#xff0c;我们…...

【计算机网络期末复习】第六章 应用层

✍个人博客&#xff1a;https://blog.csdn.net/Newin2020?spm1011.2415.3001.5343 &#x1f4e3;专栏定位&#xff1a;为想复习学校计算机网络课程的同学提供重点大纲&#xff0c;帮助大家渡过期末考~ &#x1f4da;专栏地址&#xff1a;https://blog.csdn.net/Newin2020/arti…...

TypeScript基本教程

TS是JS的超集&#xff0c;所以JS基础的类型都包含在内 起步安装 npm install typescript -g运行tsc 文件名 基础类型 Boolean、Number、String、null、undefined 以及 ES6 的 Symbol 和 ES10 的 BigInt。 1 字符串类型 字符串是使用string定义的 let a: string 123 //普…...

使用Windows API实现本地音频采集

Windows API提供了Winmm&#xff08;Windows多媒体&#xff09;库&#xff0c;其中包括了音频设备相关的函数&#xff0c;可以用来实现音频设备的枚举和测试。 下面是一个简单的示例代码&#xff0c;演示了如何使用Winmm库中的waveInGetNumDevs()函数来枚举计算机上的音频输入…...

实用的费曼学习法 | 一些思考

文章目录 一、前言二、费曼学习法CSDN 叶庭云:https://yetingyun.blog.csdn.net/ 大数据与人工智能背景下,最重要的是:捕捉机会和快速学习的能力 一、前言 费曼学习法是美国著名的物理学家,理查德 ∙ \bullet ∙ 费曼总结出来的学习方法。 这个方法的核心是:当你学习了…...

Linux安装Docker配置docker-compose 编排工具【超详细】

一、介绍Docker Docker 是一个开源的应用容器引擎&#xff0c;让开发者可以打包他们的应用以及依赖包到一个可移植的镜像中&#xff0c;然后发布到任何流行的 Linux或Windows操作系统的机器上&#xff0c;也可以实现虚拟化。容器是完全使用沙箱机制&#xff0c;相互之间不会有…...

iTerm2 + Oh My Zsh 打造舒适终端体验

最终效果图&#xff1a; 因为powerline以及homebrew均需要安装command line tool&#xff0c;网络条件优越的同学在执行本文下面内容之前&#xff0c;可以先安装XCode并打开运行一次&#xff08;会初始化安装components&#xff09;&#xff0c;省去以后在iterm2中的等待时间。…...

【scipy.sparse】diags()和dia_matrix()的区别

【scipy.sparse】diags()和dia_matrix()的区别 文章目录【scipy.sparse】diags()和dia_matrix()的区别1. 介绍2. 代码示例2.1 sp.diags()2.1.1 第一种用法&#xff08;dataoffsets&#xff09;2.1.2 广播&#xff08;需要指定shape&#xff09;2.1.3 只有一条对角线2.2 sp.dia_…...

java ssm自行车在线租赁系统idea

当前自行车在社会上广泛使用,但自行车的短距离仍旧不能完全满足广大用户的需求。自行车在线租赁系统可以为用户提供租赁用车等功能,拥有较好的用户体验.能实时在线租赁提供更加快捷方便的租车方式,解决了常见自行车在线租赁系统较为局限的自行车归还功能。 通过使用本系统&…...

conda相比python好处

Conda 作为 Python 的环境和包管理工具&#xff0c;相比原生 Python 生态&#xff08;如 pip 虚拟环境&#xff09;有许多独特优势&#xff0c;尤其在多项目管理、依赖处理和跨平台兼容性等方面表现更优。以下是 Conda 的核心好处&#xff1a; 一、一站式环境管理&#xff1a…...

java 实现excel文件转pdf | 无水印 | 无限制

文章目录 目录 文章目录 前言 1.项目远程仓库配置 2.pom文件引入相关依赖 3.代码破解 二、Excel转PDF 1.代码实现 2.Aspose.License.xml 授权文件 总结 前言 java处理excel转pdf一直没找到什么好用的免费jar包工具,自己手写的难度,恐怕高级程序员花费一年的事件,也…...

Auto-Coder使用GPT-4o完成:在用TabPFN这个模型构建一个预测未来3天涨跌的分类任务

通过akshare库&#xff0c;获取股票数据&#xff0c;并生成TabPFN这个模型 可以识别、处理的格式&#xff0c;写一个完整的预处理示例&#xff0c;并构建一个预测未来 3 天股价涨跌的分类任务 用TabPFN这个模型构建一个预测未来 3 天股价涨跌的分类任务&#xff0c;进行预测并输…...

《通信之道——从微积分到 5G》读书总结

第1章 绪 论 1.1 这是一本什么样的书 通信技术&#xff0c;说到底就是数学。 那些最基础、最本质的部分。 1.2 什么是通信 通信 发送方 接收方 承载信息的信号 解调出其中承载的信息 信息在发送方那里被加工成信号&#xff08;调制&#xff09; 把信息从信号中抽取出来&am…...

从零实现STL哈希容器:unordered_map/unordered_set封装详解

本篇文章是对C学习的STL哈希容器自主实现部分的学习分享 希望也能为你带来些帮助~ 那咱们废话不多说&#xff0c;直接开始吧&#xff01; 一、源码结构分析 1. SGISTL30实现剖析 // hash_set核心结构 template <class Value, class HashFcn, ...> class hash_set {ty…...

解决本地部署 SmolVLM2 大语言模型运行 flash-attn 报错

出现的问题 安装 flash-attn 会一直卡在 build 那一步或者运行报错 解决办法 是因为你安装的 flash-attn 版本没有对应上&#xff0c;所以报错&#xff0c;到 https://github.com/Dao-AILab/flash-attention/releases 下载对应版本&#xff0c;cu、torch、cp 的版本一定要对…...

laravel8+vue3.0+element-plus搭建方法

创建 laravel8 项目 composer create-project --prefer-dist laravel/laravel laravel8 8.* 安装 laravel/ui composer require laravel/ui 修改 package.json 文件 "devDependencies": {"vue/compiler-sfc": "^3.0.7","axios": …...

Mobile ALOHA全身模仿学习

一、题目 Mobile ALOHA&#xff1a;通过低成本全身远程操作学习双手移动操作 传统模仿学习&#xff08;Imitation Learning&#xff09;缺点&#xff1a;聚焦与桌面操作&#xff0c;缺乏通用任务所需的移动性和灵活性 本论文优点&#xff1a;&#xff08;1&#xff09;在ALOHA…...

管理学院权限管理系统开发总结

文章目录 &#x1f393; 管理学院权限管理系统开发总结 - 现代化Web应用实践之路&#x1f4dd; 项目概述&#x1f3d7;️ 技术架构设计后端技术栈前端技术栈 &#x1f4a1; 核心功能特性1. 用户管理模块2. 权限管理系统3. 统计报表功能4. 用户体验优化 &#x1f5c4;️ 数据库设…...

Fabric V2.5 通用溯源系统——增加图片上传与下载功能

fabric-trace项目在发布一年后,部署量已突破1000次,为支持更多场景,现新增支持图片信息上链,本文对图片上传、下载功能代码进行梳理,包含智能合约、后端、前端部分。 一、智能合约修改 为了增加图片信息上链溯源,需要对底层数据结构进行修改,在此对智能合约中的农产品数…...