当前位置:网站首页>20220524_ Database process_ Statement retention
20220524_ Database process_ Statement retention
2022-07-02 23:09:00 【szc_ one thousand nine hundred and eighty-five】
One day outbound number exceeds 10 individual , At the same time, the dispersion of outbound numbers is greater than 0.8, And the outbound number is close to 10 Call numbers inside and outside the day do not overlap .
Field required : number 、 Number of caller calls 、 Caller dispersion 、 Number overlap rate
use zibo_oracle_new;
drop table if EXISTS lw_yyth_hmlsd_ycjk_hzjg;
create table lw_yyth_hmlsd_ycjk_hzjg(
cycle_time varchar2(8),PRODUCT_NO varchar2(20), min_TIME datetime, max_TIME datetime, ROAMCITYs decimal(21), CELL_IDs decimal(21),
IMEIs decimal(21), OPP_CITYs decimal(21), th_cs_zong decimal(21), th_hm_zong decimal(21),
zj_cs_zong decimal(21),zj_hm_zong decimal(21), zj_lsd decimal(26,2), OPPOSITE_NOs decimal(21),
OPPOSITE_NO_q decimal(21)
)engine=oracle.zibo_new;
# Sign in zibo
use zibo;
# The number of caller calls of a number is greater than or equal to 10 Time , Outbound number dispersion 0.8 And above # Detail data generation
drop table if EXISTS lw_yyth_hmlsd_ycjk_mx;
create table lw_yyth_hmlsd_ycjk_mx as
select USER_ID,PRODUCT_NO,CALLTYPE_ID,OPPOSITE_NO,THIRDTELNUM,CALL_DURATION,CALL_DURATION_M,
START_DATETIME,ROAMCITY_ID,OPP_CITY_ID,OPPOSITE_ROAMCITY_ID,LAC_ID,CELL_ID,‘ voice ’ huadan_typename,IMEI
from zibo.cdr_call_${dayid} a ;
# Summarize by number , Screening
drop table if EXISTS lw_yyth_hmlsd_ycjk_hz;
create table lw_yyth_hmlsd_ycjk_hz as
select a.PRODUCT_NO,
min(START_DATETIME) min_TIME,
max(START_DATETIME) max_TIME,
count(distinct ROAMCITY_ID) ROAMCITYs,
count(distinct CELL_ID) CELL_IDs,
count(distinct IMEI) IMEIs,
count(distinct OPP_CITY_ID) OPP_CITYs,
count(a.OPPOSITE_NO) th_cs_zong,
count(distinct a.OPPOSITE_NO) th_hm_zong,
sum(CALL_DURATION_M) CALL_DURATION_M,
count(case when CALLTYPE_ID=‘1’ then a.OPPOSITE_NO end) zj_cs_zong,
count(distinct case when CALLTYPE_ID=‘1’ then a.OPPOSITE_NO end) zj_hm_zong,
sum(nvl(case when CALLTYPE_ID=‘1’ then a.CALL_DURATION_M end,0)) zj_DURATION_M,
round(count( distinct case when CALLTYPE_ID=‘1’ then a.OPPOSITE_NO end)/
count( case when CALLTYPE_ID=‘1’ then a.OPPOSITE_NO end)*100,2) zj_lsd
from lw_yyth_hmlsd_ycjk_mx a
group by a.PRODUCT_NO
having count( case when CALLTYPE_ID=‘1’ then a.OPPOSITE_NO end) >=10;
drop table if EXISTS lw_yyth_hmlsd_ycjk_hza;
create table lw_yyth_hmlsd_ycjk_hza as
select * from lw_yyth_hmlsd_ycjk_hz a where a.zj_lsd>=80;
# In line with the number bill details
drop table if EXISTS lw_yyth_hmlsd_ycjk_mxs;
create table lw_yyth_hmlsd_ycjk_mxs as
select PRODUCT_NO,OPPOSITE_NO,count(OPPOSITE_NO) count_cs,sum(CALL_DURATION_M) CALL_DURATION_M from lw_yyth_hmlsd_ycjk_mx a
where exists (select 1 from lw_yyth_hmlsd_ycjk_hza t where a.PRODUCT_NO=t.PRODUCT_NO)
and CALLTYPE_ID=‘1’
group by PRODUCT_NO,OPPOSITE_NO;
near 10 Call status of these numbers for days
drop table if EXISTS lw_yyth_hmlsd_ycjk_qjtmx;
create table lw_yyth_hmlsd_ycjk_qjtmx as
front 1 God
select PRODUCT_NO,START_DATETIME,ROAMCITY_ID,LAC_ID,CELL_ID ,‘ voice ’ huadan_typename,IMEI,OPPOSITE_NO,CALLTYPE_ID
from zibo.cdr_call_${pdayid} a where exists (select 1 from lw_yyth_hmlsd_ycjk_hza t where a.PRODUCT_NO=t.PRODUCT_NO) and CALLTYPE_ID =‘1’
union all
front 2 God
select PRODUCT_NO,START_DATETIME,ROAMCITY_ID,LAC_ID,CELL_ID ,‘ voice ’,IMEI ,OPPOSITE_NO,CALLTYPE_ID
from zibo.cdr_call_${p2dayid} a where exists (select 1 from lw_yyth_hmlsd_ycjk_hza t where a.PRODUCT_NO=t.PRODUCT_NO) and CALLTYPE_ID =‘1’
union all
front 3 God
select PRODUCT_NO,START_DATETIME,ROAMCITY_ID,LAC_ID,CELL_ID ,‘ voice ’,IMEI ,OPPOSITE_NO,CALLTYPE_ID
from zibo.cdr_call_${p3dayid} a where exists (select 1 from lw_yyth_hmlsd_ycjk_hza t where a.PRODUCT_NO=t.PRODUCT_NO) and CALLTYPE_ID =‘1’
union all
front 4 God
select PRODUCT_NO,START_DATETIME,ROAMCITY_ID,LAC_ID,CELL_ID ,‘ voice ’,IMEI ,OPPOSITE_NO,CALLTYPE_ID
from zibo.cdr_call_${p4dayid} a where exists (select 1 from lw_yyth_hmlsd_ycjk_hza t where a.PRODUCT_NO=t.PRODUCT_NO) and CALLTYPE_ID =‘1’
union all
front 5 God
select PRODUCT_NO,START_DATETIME,ROAMCITY_ID,LAC_ID,CELL_ID ,‘ voice ’,IMEI ,OPPOSITE_NO,CALLTYPE_ID
from zibo.cdr_call_${p5dayid} a where exists (select 1 from lw_yyth_hmlsd_ycjk_hza t where a.PRODUCT_NO=t.PRODUCT_NO) and CALLTYPE_ID =‘1’
union all
front 6 God
select PRODUCT_NO,START_DATETIME,ROAMCITY_ID,LAC_ID,CELL_ID ,‘ voice ’,IMEI ,OPPOSITE_NO,CALLTYPE_ID
from zibo.cdr_call_${p6dayid} a where exists (select 1 from lw_yyth_hmlsd_ycjk_hza t where a.PRODUCT_NO=t.PRODUCT_NO) and CALLTYPE_ID =‘1’
union all
front 7 God
select PRODUCT_NO,START_DATETIME,ROAMCITY_ID,LAC_ID,CELL_ID ,‘ voice ’,IMEI ,OPPOSITE_NO,CALLTYPE_ID
from zibo.cdr_call_${p7dayid} a where exists (select 1 from lw_yyth_hmlsd_ycjk_hza t where a.PRODUCT_NO=t.PRODUCT_NO) and CALLTYPE_ID =‘1’
union all
front 8 God
select PRODUCT_NO,START_DATETIME,ROAMCITY_ID,LAC_ID,CELL_ID ,‘ voice ’,IMEI ,OPPOSITE_NO,CALLTYPE_ID
from zibo.cdr_call_${p8dayid} a where exists (select 1 from lw_yyth_hmlsd_ycjk_hza t where a.PRODUCT_NO=t.PRODUCT_NO) and CALLTYPE_ID =‘1’
;
drop table if EXISTS lw_yyth_hmlsd_ycjk_qjthz;
create table lw_yyth_hmlsd_ycjk_qjthz as
select a.PRODUCT_NO,a.OPPOSITE_NO,count( distinct substr(START_DATETIME,1,10)) count_day,count(a.OPPOSITE_NO) count_cs
from lw_yyth_hmlsd_ycjk_qjtmx a
group by a.PRODUCT_NO,a.OPPOSITE_NO;
Number data integration
drop table if EXISTS lw_yyth_hmlsd_ycjk_hmhzzl;
create table lw_yyth_hmlsd_ycjk_hmhzzl as
select t1.PRODUCT_NO,t1.OPPOSITE_NO,t1.count_cs,t1.CALL_DURATION_M,t2.count_day,t2.count_cs qt_count_cs
from lw_yyth_hmlsd_ycjk_mxs t1
left join lw_yyth_hmlsd_ycjk_qjthz t2
on t1.PRODUCT_NO=t2.PRODUCT_NO
and t1.OPPOSITE_NO=t2.OPPOSITE_NO ;
drop table if EXISTS lw_yyth_hmlsd_ycjk_hmhzzla;
create table lw_yyth_hmlsd_ycjk_hmhzzla as
select a.PRODUCT_NO,count( distinct a.OPPOSITE_NO) OPPOSITE_NOs,
count( distinct case when qt_count_cs is not null then a.OPPOSITE_NO end ) OPPOSITE_NO_q
from lw_yyth_hmlsd_ycjk_hmhzzl a
group by a.PRODUCT_NO;
The results derived
drop table if EXISTS lw_yyth_hmlsd_ycjk_hzjg;
create table lw_yyth_hmlsd_ycjk_hzjg as
select ${dayid} cycle,a.*,b.OPPOSITE_NOs,b.OPPOSITE_NO_q
from lw_yyth_hmlsd_ycjk_hza a,
lw_yyth_hmlsd_ycjk_hmhzzla b
where a.PRODUCT_NO=b.PRODUCT_NO;
Import data
insert into zibo_oracle_new.lw_yyth_hmlsd_ycjk_hzjg
select cycle ,PRODUCT_NO,min_TIME,max_TIME,ROAMCITYs,CELL_IDs ,
IMEIs ,OPP_CITYs,th_cs_zong,th_hm_zong ,
zj_cs_zong , zj_hm_zong , zj_lsd , OPPOSITE_NOs , OPPOSITE_NO_q
from lw_yyth_hmlsd_ycjk_hzjg ;
# Another data platform
SQL_STRING:=’ insert into shzc.lw_yyth_hmlsd_ycjk_hzbd
select a.cycle_time date ,
a.product_no number ,
a.min_time The earliest call time ,
a.max_time Last call time ,
b.start_datetime Last time ,
b.roamcity_name Finally, use the city ,
b.huadan_typename Last type ,
b.county_id Finally, districts and counties ,
b.bts_name Finally, the base station ,
ROAMCITYS Number of roaming cities ,
CELL_IDS Number of base stations used ,
IMEIS Use serial number ,
OPP_CITYS The number of other cities ,
a.th_cs_zong Number of calls per day ,
a.th_hm_zong Number of daily calls ,
a.zj_cs_zong Daily calling times ,
a.zj_hm_zong Number of daily calling numbers ,
a.zj_lsd Day call dispersion ,
a.opposite_no_q Number of overlaps ,
round(a.opposite_no_q/a.opposite_nos*100,2) Number overlap rate
from zibo.lw_yyth_hmlsd_ycjk_hzjg a ,
zibo.lw_sasz_xdjl_zhsy_bd b
where --a.opposite_no_q/a.opposite_nos>=0.8
–and
a.product_no=b.product_no(+) ’ ;
execute immediate (SQL_STRING);
commit;
----- Early warning near 4 The sky is abnormal , And will 15 Data cleared days ago , Reduce data storage pressure
fan_drop_retable(upper('lw_yyth_hmlsd_ycjk_daypm'),'SHZC');
SQL_STRING:='create table shzc.lw_yyth_hmlsd_ycjk_daypm as
select a. date ,row_number() over (partition by 1 order by a. date desc ) ranking
from shzc.lw_yyth_hmlsd_ycjk_hzbd a
group by a. date ' ;
execute immediate (SQL_STRING);
-- Data clearing
SQL_STRING:='delete from shzc.lw_yyth_hmlsd_ycjk_hzbd a
where exists (select 1 from shzc.lw_yyth_hmlsd_ycjk_daypm b where b. ranking >15 and a. date =b. date ) ' ;
execute immediate (SQL_STRING);
commit;
fan_drop_retable(upper('lw_yyth_hmlsd_ycjk_fzmxa'),'SHZC');
SQL_STRING:='create table shzc.lw_yyth_hmlsd_ycjk_fzmxa as
select a.*,b. ranking from shzc.lw_yyth_hmlsd_ycjk_hzbd a,
shzc.lw_yyth_hmlsd_ycjk_daypm b
where a. number in (
select a. number from shzc.lw_yyth_hmlsd_ycjk_hzbd a
where exists (select 1 from shzc.lw_yyth_hmlsd_ycjk_daypm b where b. ranking <5 and a. date =b. date )
group by a. number
having count(*)>3)
and a. date =b. date
and exists (select 1 from shzc.lw_yyth_hmlsd_ycjk_daypm b where b. ranking <5 and a. date =b. date )' ;
execute immediate (SQL_STRING);
fan_drop_retable(upper('lw_yyth_hmlsd_ycjk_fzmxb'),'SHZC');
SQL_STRING:='create table shzc.lw_yyth_hmlsd_ycjk_fzmxb as
select a. number ,max(a. date ) date ,
max(nvl(case when a. ranking =4 then a. Number of base stations used end,0)) y4 Use base stations ,
max(nvl(case when a. ranking =4 then a. The number of other cities end,0)) y4 The other city ,
max(nvl(case when a. ranking =4 then a. Daily calling times end,0)) y4 Daily calling times ,
max(nvl(case when a. ranking =4 then a. Day call dispersion end,0)) y4 Day call dispersion ,
max(nvl(case when a. ranking =4 then a. Number overlap rate end,0)) y4 Number overlap rate ,
max(nvl(case when a. ranking =3 then a. Number of base stations used end,0)) y3 Use base stations ,
max(nvl(case when a. ranking =3 then a. The number of other cities end,0)) y3 The other city ,
max(nvl(case when a. ranking =3 then a. Daily calling times end,0)) y3 Daily calling times ,
max(nvl(case when a. ranking =3 then a. Day call dispersion end,0)) y3 Day call dispersion ,
max(nvl(case when a. ranking =3 then a. Number overlap rate end,0)) y3 Number overlap rate ,
max(nvl(case when a. ranking =2 then a. Number of base stations used end,0)) y2 Use base stations ,
max(nvl(case when a. ranking =2 then a. The number of other cities end,0)) y2 The other city ,
max(nvl(case when a. ranking =2 then a. Daily calling times end,0)) y2 Daily calling times ,
max(nvl(case when a. ranking =2 then a. Day call dispersion end,0)) y2 Day call dispersion ,
max(nvl(case when a. ranking =2 then a. Number overlap rate end,0)) y2 Number overlap rate ,
max(nvl(case when a. ranking =1 then a. Number of base stations used end,0)) y1 Use base stations ,
max(nvl(case when a. ranking =1 then a. The number of other cities end,0)) y1 The other city ,
max(nvl(case when a. ranking =1 then a. Daily calling times end,0)) y1 Daily calling times ,
max(nvl(case when a. ranking =1 then a. Day call dispersion end,0)) y1 Day call dispersion ,
max(nvl(case when a. ranking =1 then a. Number overlap rate end,0)) y1 Number overlap rate
from shzc.lw_yyth_hmlsd_ycjk_fzmxa a
where A. Number overlap rate <=20
and a. Number of base stations used <10
group by a. number
having count(distinct a. date )=4' ;
execute immediate (SQL_STRING);
fan_drop_retable(upper('lw_yyth_hmlsd_ycjk_fzmxc'),'SHZC');
SQL_STRING:='create table shzc.lw_yyth_hmlsd_ycjk_fzmxc as
select a.* from
(select a. number ,b.servnumber hm,b.subsid,b.acctid,b.prodid,pp.prodname,B.STATUS,zt.dictname state ,b.statusdate State time ,
b.createdate Network access time ,b.settleday Accounting period date ,B.ENUM,B.IMSI,B.REGISTERORGID,B.OWNERORGID,
row_number() over (partition by a. number order by nvl(b.createdate,sysdate-9999) desc ) ranking
from shzc.lw_yyth_hmlsd_ycjk_fzmxb a,(select * from zhyw.subscriber b where b.status not in (''US26'',''US28'') /*and b.active=1*/ ) B ,
(select * from [email protected] where groupid=''US'') zt ,[email protected] pp
where a. number =b.servnumber(+)
and zt.dictid(+)=b.status
and pp.prodid(+)=b.prodid) a
where ranking =1' ;
execute immediate (SQL_STRING);
SQL_STRING:='delete from shzc.lw_yyth_hmlsd_ycjk_fzmx_bd a where date ='''||P_DAY||''' ' ;
execute immediate (SQL_STRING);
commit;
SQL_STRING:=' insert into shzc.lw_yyth_hmlsd_ycjk_fzmx_bd
select a. date ,
a. number ,
b.subsid,
b. Network access time ,
b.registerorgid,
e.orgname,
a.y4 Use base stations ,
a.y4 The other city ,
a.y4 Daily calling times ,
a.y4 Day call dispersion ,
a.y4 Number overlap rate ,
a.y3 Use base stations ,
a.y3 The other city ,
a.y3 Daily calling times ,
a.y3 Day call dispersion ,
a.y3 Number overlap rate ,
a.y2 Use base stations ,
a.y2 The other city ,
a.y2 Daily calling times ,
a.y2 Day call dispersion ,
a.y2 Number overlap rate ,
a.y1 Use base stations ,
a.y1 The other city ,
a.y1 Daily calling times ,
a.y1 Day call dispersion ,
a.y1 Number overlap rate
from shzc.lw_yyth_hmlsd_ycjk_fzmxb a,
shzc.lw_yyth_hmlsd_ycjk_fzmxc b,
[email protected] e
where a. number =b. number
and b.registerorgid=e.orgid(+) ' ;
execute immediate (SQL_STRING);
commit;
边栏推荐
- Qt QScrollArea
- 深度剖析数据在内存中的存储----C语言篇
- Stop slave is stuck -- the event of the transaction is not copied completely
- 移动端 1px 像素兼容性问题,实现1px 边框
- The motivation of AES Advanced Encryption Protocol
- PMP project integration management
- Jielizhi, production line assembly link [chapter]
- Static file display problem
- Redis 过期策略+conf 记录
- MySQL查询附近的数据.并按距离进行排序.
猜你喜欢
Construction of Hisilicon 3559 universal platform: draw a frame on the captured YUV image
Chow-Liu Tree
PMP project integration management
容器化技术在嵌入式领域的应用
ServletContext learning diary 1
設置單擊右鍵可以選擇用VS Code打開文件
Lambda expression: an article takes you through
QT qpprogressbar details
Successfully changed Splunk default URL root path
LeetCode 968. 监控二叉树
随机推荐
Jerry's built-in shutdown current is 1.2ua, and then it can't be turned on by long pressing [chapter]
PMP project integration management
Webrtc audio and video capture and playback examples and mediastream media stream analysis
【硬件】标准阻值的由来
Stop slave is stuck -- the event of the transaction is not copied completely
海思 VI接入视频流程
antd组件upload上传xlsx文件,并读取文件内容
P7072 [csp-j2020] live broadcast Award
2016. 增量元素之间的最大差值
2016. maximum difference between incremental elements
Array advanced improvement
详解Promise使用
Editor Caton
创新实力再获认可!腾讯安全MSS获2022年度云原生安全守护先锋
Freshman learning sharing
Static file display problem
用matlab调用vs2015来编译vs工程
Strictly abide by the construction period and ensure the quality, this AI data annotation company has done it!
Jinglianwen technology's low price strategy helps AI enterprises reduce model training costs
pytorch训练CPU占用持续增长(bug)