Merge branch 'feature-data' of http://222.76.244.118:3000/CPICXIM/desktop_task_schedule into feature-data

This commit is contained in:
unknown 2023-06-04 19:51:45 +08:00
commit ec18d20461
4 changed files with 347 additions and 314 deletions

View File

@ -35,16 +35,18 @@ CREATE OR REPLACE PACKAGE BODY telsale_archievement_pkg IS
a_mensual_cur OUT cur_type
) IS
l_this_month VARCHAR2(4);
l_this_year DATE;
l_this_year VARCHAR2(4);
l_firstday DATE;
l_department_name VARCHAR2(100);
BEGIN
l_this_month := to_char(SYSDATE,
'mm') || '月';
l_this_year := to_date(to_char(SYSDATE,
'yyyy') || '-01-01 00:00:00',
'yyyy-mm-dd hh24:mi:ss');
'mm');
l_this_year := to_char(SYSDATE,
'yyyy');
l_firstday := to_date(to_char(SYSDATE,
'yyyy') || '-01-01 00:00:00',
'yyyy-mm-dd hh24:mi:ss');
-- 取得部门代码
SELECT bm.department_name
INTO l_department_name
FROM idst0.bm_t bm
@ -57,8 +59,9 @@ CREATE OR REPLACE PACKAGE BODY telsale_archievement_pkg IS
round((SUM(cf.车非融合保费) / SUM(cf.车险个人客户保费) * 100),
2))
INTO a_attaching_rate
FROM 车非每日保费 cf
FROM 坐席车非每日保费 cf
WHERE cf.月份 = l_this_month
AND cf.年份 = l_this_year
AND 部门代码 = a_department_code;
--续保率
@ -76,9 +79,9 @@ CREATE OR REPLACE PACKAGE BODY telsale_archievement_pkg IS
0),
0)
INTO a_total
FROM 车非每日保费 cf
FROM 坐席车非每日保费 cf
WHERE 部门代码 = a_department_code
AND 签单日期 >= l_this_year
AND 签单日期 >= l_firstday
AND 签单日期 <= SYSDATE;
--每月业绩
@ -87,7 +90,7 @@ CREATE OR REPLACE PACKAGE BODY telsale_archievement_pkg IS
round(nvl(SUM(cf.车险个人客户保费 + cf.车非融合保费) / 10000,
0),
0) bf
FROM 车非每日保费 cf
FROM 坐席车非每日保费 cf
WHERE 部门代码 = a_department_code
AND 签单日期 >= to_date(to_char(SYSDATE,
'yyyy') || '-01-01 00:00:00',
@ -105,21 +108,25 @@ CREATE OR REPLACE PACKAGE BODY telsale_archievement_pkg IS
a_chefei_ranking_list OUT cur_type
) IS
l_current_month VARCHAR2(10);
l_current_year VARCHAR2(4);
BEGIN
l_current_month := to_char(SYSDATE,
'mm') || '月';
'mm');
l_current_year := to_char(SYSDATE,
'yyyy');
OPEN a_chefei_ranking_list FOR
SELECT 坐席名称,
round(SUM(车非融合保费) / SUM(车险个人客户保费) * 100,
2) 车非渗透率
FROM 车非每日保费
FROM 坐席车非每日保费
WHERE 月份 = l_current_month
AND 年份 = l_current_year
AND 部门代码 = a_department_code
GROUP BY 月份,
部门代码,
坐席名称
HAVING 月份 = '06月'
--HAVING 月份 = '06月'
ORDER BY 车非渗透率 DESC;
END;

View File

@ -61,6 +61,8 @@ CREATE OR REPLACE PACKAGE BODY telsale_pkg IS
NULL;
END;
/**********************************************************************/
PROCEDURE gen_车非临时数据
(
a_start_date IN DATE,
@ -69,12 +71,14 @@ CREATE OR REPLACE PACKAGE BODY telsale_pkg IS
BEGIN
desktop_archievement_admin.clean_temp_data;
INSERT INTO desktop_archievement_admin.车非每日保费_t
INSERT INTO desktop_archievement_admin.坐席车非每日保费_t
WITH aa AS
(SELECT to_char(t.signature_date,
'yyyy-mm-dd') 签单日期,
(to_char(T.signature_date,
'mm')) || '月' mm,
'yyyy')) the_year,
(to_char(T.signature_date,
'mm')) the_month,
t.policy_no bdh,
t.endorsement_no pdh,
qt.t_cre tid,
@ -189,7 +193,8 @@ CREATE OR REPLACE PACKAGE BODY telsale_pkg IS
,
dd2 AS
(SELECT 签单日期,
mm,
the_year,
the_month,
bm,
bmdm,
坐席工号,
@ -215,7 +220,8 @@ CREATE OR REPLACE PACKAGE BODY telsale_pkg IS
WHEN pdh = '无' THEN
tid
END,
mm,
the_year,
the_month,
BTID,
坐席工号,
坐席名称,
@ -225,7 +231,8 @@ CREATE OR REPLACE PACKAGE BODY telsale_pkg IS
经办人N
UNION
SELECT 签单日期,
mm,
the_year,
the_month,
bm,
bmdm,
坐席工号,
@ -257,7 +264,7 @@ CREATE OR REPLACE PACKAGE BODY telsale_pkg IS
to_number(to_char(q.signature_date,
'yyyy')) || '年' nf,
(to_char(q.signature_date,
'mm')) || '月' mm_f,
'mm')) mm_f,
to_char(q.signature_date,
'dd') || '日' dd,
q.signature_date sj,
@ -334,11 +341,12 @@ CREATE OR REPLACE PACKAGE BODY telsale_pkg IS
FROM dd
LEFT JOIN cc
ON cc.融合证件 = dd.tid
AND cc.mm_f = dd.mm) --OR cc.融合证件 = dd.btid
AND cc.mm_f = dd.the_month) --OR cc.融合证件 = dd.btid
--select * from ff
SELECT to_date(签单日期,
'yyyy-mm-dd') 签单日期,
mm 月份,
the_year 年份,
the_month 月份,
bm 部门,
bmdm 部门代码,
科室N,
@ -358,7 +366,8 @@ CREATE OR REPLACE PACKAGE BODY telsale_pkg IS
AND bm IN ('续保业务部',
'湖里支公司')
GROUP BY 签单日期,
mm,
the_year,
the_month,
bm,
bmdm,
坐席工号,
@ -371,6 +380,8 @@ CREATE OR REPLACE PACKAGE BODY telsale_pkg IS
COMMIT;
END;
/**********************************************************************/
PROCEDURE 续保基本数据 IS
BEGIN
--清理旧数据

View File

@ -27,7 +27,7 @@ SELECT *
WHERE t.team_code = '107077'
SELECT *
FROM
FROM
ORDER BY ,
;
@ -48,7 +48,7 @@ SELECT
SUM(),
round(SUM() / SUM() * 100,
2)
FROM
FROM
GROUP BY ,
,
@ -59,8 +59,12 @@ HAVING
SELECT ,
round(SUM() / SUM() * 100,
2)
FROM
FROM
WHERE = 'QDI'
AND = '06月'
GROUP BY
ORDER BY DESC;
--
SELECT *
FROM

View File

@ -1,48 +1,36 @@
--INSERT INTO desktop_archievement_admin._t
WITH aa AS
(SELECT to_char(t.signature_date,
'yyyy-mm-dd') ,
(to_char(T.signature_date,
'mm')) || '' mm,
t.policy_no bdh,
t.endorsement_no pdh,
qt.t_cre tid,
QT.B_CRE BTID, -----
e.inception_date qbsj,
e.planned_end_date zzsj,
pt.premium_amount - nvl(pt.tax_amount,
0) bf
--,qt.qdbf - nvl(qt.qdbf_tax_amount,0) bf
,
nt.ecompensation_rate * (pt.premium_amount - nvl(pt.tax_amount,
0)) fxbf,
z.department_name bm,
z.department_code bmdm,
CASE
WHEN (et.telpartnercode LIKE '%HC%' OR zx.workerno IN (SELECT code
FROM datacenter.dc_lsj_zx_hc)) THEN
'海沧丰骏'
ELSE
''
END ,
nvl(zx.workerno,
et.telpartnercode) ,
(CASE
WHEN nvl(zx.workerno,
et.telpartnercode) = 'DX001' AND
xx.staff_name LIKE '%建发凯迪%' THEN
'林伟华'
WHEN nvl(zx.workerno,
et.telpartnercode) = 'DX001' AND
xx.staff_name NOT LIKE '%建发凯迪%' THEN
'其他'
ELSE
to_char(ys.)
END) ,
YS. ,
nvl(YS.,
y.section_office_name) N,
nvl((CASE
INSERT INTO desktop_archievement_admin.
WITH aa AS
(SELECT to_char(t.signature_date,
'yyyy-mm-dd') ,
(to_char(T.signature_date,
'yyyy')) the_year,
(to_char(T.signature_date,
'mm')) the_month,
t.policy_no bdh,
t.endorsement_no pdh,
qt.t_cre tid,
QT.B_CRE BTID, -----
e.inception_date qbsj,
e.planned_end_date zzsj,
pt.premium_amount - nvl(pt.tax_amount,
0) bf
--,qt.qdbf - nvl(qt.qdbf_tax_amount,0) bf
,
nt.ecompensation_rate * (pt.premium_amount - nvl(pt.tax_amount,
0)) fxbf,
z.department_name bm,
z.department_code bmdm,
CASE
WHEN (et.telpartnercode LIKE '%HC%' OR
zx.workerno IN (SELECT code
FROM datacenter.dc_lsj_zx_hc)) THEN
'海沧丰骏'
ELSE
''
END ,
nvl(zx.workerno,
et.telpartnercode) ,
(CASE
WHEN nvl(zx.workerno,
et.telpartnercode) = 'DX001' AND
xx.staff_name LIKE '%建发凯迪%' THEN
@ -53,246 +41,269 @@ WITH aa AS
'其他'
ELSE
to_char(ys.)
END),
xx.staff_name) N
FROM idst0.auto_agreement_request_t t
LEFT JOIN idst0.auto_agreement_t e
ON e.policy_no = t.policy_no
LEFT JOIN idst0.motorised_vehicle_t v
ON v.policy_no = e.policy_no
LEFT JOIN idst0.auto_premium_t pt
ON pt.policy_no = t.policy_no
AND pt.endorsement_no = t.endorsement_no
LEFT JOIN ywglxt.w_dxbd_i i
ON e.policy_no = i.bdh
LEFT JOIN idst0.rydm_t xx
ON xx.staff_code = nvl(i.zhjywy,
e.operator_code)
LEFT JOIN idst0.ks_t y
ON y.section_office_code = nvl(xx.section_office_code,
e.section_office_code)
LEFT JOIN idst0.bm_t z
ON z.department_code = nvl(xx.department_code,
e.department_code)
--left join datacenter.dc_cx_csteam ct on ct.jbrcode = xx.staff_code
LEFT JOIN idst0.auto_new_product_info_t nt
ON nt.policy_no = t.policy_no
AND nt.endorsement_no = t.endorsement_no
--left join ywglxt.q_auto_agreement_extend_t qe on qe.policy_no = e.policy_no
LEFT JOIN ywglxt.q_auto_agreement_t qt
ON qt.policy_no = e.policy_no
LEFT JOIN datacenter.dc_yangg_qdcode qd
ON qd.code = e.selling_channel_type
LEFT JOIN datacenter.dc_tb_jc_c_tag cl
ON cl. = e.policy_no
LEFT JOIN datacenter.dc_yangg_basecode_teams fg
ON fg.bm = z.department_name
AND fg.ks = y.section_office_name
--left join idst0.t_sell_policy_autobase_t zx on zx.policy_no=e.policy_no
--left join idst0.auto_agreement_extend_t et on et.policy_no = e.policy_no
LEFT JOIN idst0.auto_agreement_extend_t et
ON et.policy_no = e.policy_no
LEFT JOIN idst0.t_sell_policy_autobase_t zx
ON zx.policy_no = e.policy_no
LEFT JOIN datacenter.dc_YZH_ZXYS YS
ON YS. = nvl(zx.workerno,
et.telpartnercode)
--left join v_lsj_dimian dm on dm.vin=v.vin and e.selling_channel_type='25' and dm.MEMO like'%地面续保%'
--left join datacenter.dc_lsj_zx_team zt on zt.name=coalesce(zc.name,zc1.name,bc.name,dm.JBRMC)
WHERE t.signature_date >= to_date('2023-01-01 00:00:00',
'yyyy-mm-dd hh24:mi:ss')
AND t.signature_date < to_date(to_char(SYSDATE - 1,
'yyyy-mm-dd') || ' 23:59:59',
'yyyy-mm-dd hh24:mi:ss')
--and t.endorsement_no = ''
AND e.policy_status = '1' --
AND qt.tflag = '0' --
AND qt.usage_xm = '家庭自用车'
--
--and e.policy_no in ('AXIMC90Y1419B038594J','AXIMC90CTP19B039593R','AXIMC04CTP19B013473X')
AND e.planned_end_date - e.inception_date >= 360
--
)
-----
,
dd2 AS
(SELECT ,
mm,
bm,
bmdm,
,
,
,
N,
N,
CASE
WHEN pdh = '' THEN
tid
END tid,
to_number('1') ,
COUNT(DISTINCT CASE
WHEN pdh = '' THEN
bdh
END) ,
SUM(bf)
FROM (SELECT DISTINCT *
FROM aa) aa
GROUP BY bm,
bmdm,
CASE
WHEN pdh = '' THEN
tid
END,
mm,
BTID,
,
,
,
,
N,
N
UNION
SELECT ,
mm,
bm,
bmdm,
,
,
,
N,
N,
CASE
WHEN btid = tid THEN
''
ELSE
btid
END btid,
to_number('0') ,
to_number('0') ,
to_number('0')
FROM (SELECT DISTINCT *
FROM aa) aa),
DD AS
(SELECT *
FROM DD2
WHERE TID IS NOT NULL)
--select * from dd
,
bb AS
(SELECT DISTINCT q.policy_no bdh,
q.endorsement_no pdh,
qna.t_cre tid,
to_number(to_char(q.signature_date,
'yyyy')) || '' nf,
(to_char(q.signature_date,
'mm')) || '' mm_f,
to_char(q.signature_date,
'dd') || '' dd,
q.signature_date sj,
round((pt.premium_amount - nvl(pt.taxamount,
0)) * c.rate / 100,
2) bf,
z.department_name bm
FROM idst0.nonauto_agreement_request_t q
LEFT JOIN idst0.nonauto_agreement_t e
ON e.policy_no = q.policy_no
LEFT JOIN idst0.nonauto_premium_t pt
ON pt.endorsement_no = q.endorsement_no
AND pt.policy_no = q.policy_no
LEFT JOIN idst0.reinsurance_t r
ON r.reinsurance_policy_no = e.policy_no
LEFT JOIN idst0.exrate_month_t c
ON pt.currency_code = c.bzh
AND to_char(q.signature_date,
'YYYY') = c.theyear
AND to_char(q.signature_date,
'fmmm') = c.themonth
LEFT JOIN idst0.rydm_t x
ON x.staff_code = e.operator_code
LEFT JOIN idst0.ks_t y
ON y.section_office_code = x.section_office_code
LEFT JOIN idst0.bm_t z
ON z.department_code = x.department_code
LEFT JOIN ywglxt.q_nonauto_agreement_t qna
ON qna.policy_no = q.policy_no
LEFT JOIN datacenter.dc_yangg_gkxzh gk
ON gk.product_code = e.product_code --
--left join datacenter.dc_yangg_zbxzh zb on zb.product_code = e.product_code --
LEFT JOIN dd
ON dd.tid = qna.t_cre
WHERE qna.tflag = '0'
AND (CASE
WHEN q.endorsement_no != '' AND
round((pt.premium_amount - nvl(pt.taxamount,
0)) * c.rate / 100,
2) != 0 THEN
''
END) IS NULL
--and q.endorsement_no = ''
AND e.policy_status = '1'
AND gk.product_code IS NOT NULL
AND (e.product_code LIKE '2%' OR e.product_code LIKE '1106%' -- --
OR e.product_code LIKE '1107%' OR e.product_code LIKE '1108%' OR e.product_code LIKE '1307%' OR e.product_code LIKE '1304A400%' --
)
--and e.product_code not in ('22KC9800')
AND q.signature_date >= to_date('2023-01-01 00:00:00',
'yyyy-mm-dd hh24:mi:ss')
AND q.signature_date < to_date(to_char(SYSDATE - 1,
'yyyy-mm-dd') || ' 23:59:59',
'yyyy-mm-dd hh24:mi:ss')
AND e.planned_end_date - e.inception_date >= 90
AND dd.tid IS NOT NULL
--)
)
--SELECT * FROM BB
,
cc AS
(SELECT mm_f,
tid ,
COUNT(DISTINCT bdh) ,
SUM(bf)
FROM bb
GROUP BY tid,
mm_f),
ff AS
(SELECT dd.*,
cc.*
FROM dd
LEFT JOIN cc
ON cc. = dd.tid
AND cc.mm_f = dd.mm) --OR cc. = dd.btid
--select * from ff
SELECT to_date(,
'yyyy-mm-dd') ,
mm ,
bm ,
bmdm ,
N,
N,
,
,
,
nvl(SUM(),
0) ,
nvl(SUM(),
0)
FROM ff
WHERE ff. >= to_char(SYSDATE - 3,
'yyyy-mm-dd')
AND ff. <= to_char(SYSDATE,
'yyyy-mm-dd')
AND bm IN ('续保业务部',
'湖里支公司')
GROUP BY ,
mm,
bm,
bmdm,
,
,
,
N,
N
ORDER BY ,
;
END) ,
YS. ,
nvl(YS.,
y.section_office_name) N,
nvl((CASE
WHEN nvl(zx.workerno,
et.telpartnercode) = 'DX001' AND
xx.staff_name LIKE '%建发凯迪%' THEN
'林伟华'
WHEN nvl(zx.workerno,
et.telpartnercode) = 'DX001' AND
xx.staff_name NOT LIKE '%建发凯迪%' THEN
'其他'
ELSE
to_char(ys.)
END),
xx.staff_name) N
FROM idst0.auto_agreement_request_t t
LEFT JOIN idst0.auto_agreement_t e
ON e.policy_no = t.policy_no
LEFT JOIN idst0.motorised_vehicle_t v
ON v.policy_no = e.policy_no
LEFT JOIN idst0.auto_premium_t pt
ON pt.policy_no = t.policy_no
AND pt.endorsement_no = t.endorsement_no
LEFT JOIN ywglxt.w_dxbd_i i
ON e.policy_no = i.bdh
LEFT JOIN idst0.rydm_t xx
ON xx.staff_code = nvl(i.zhjywy,
e.operator_code)
LEFT JOIN idst0.ks_t y
ON y.section_office_code = nvl(xx.section_office_code,
e.section_office_code)
LEFT JOIN idst0.bm_t z
ON z.department_code = nvl(xx.department_code,
e.department_code)
--left join datacenter.dc_cx_csteam ct on ct.jbrcode = xx.staff_code
LEFT JOIN idst0.auto_new_product_info_t nt
ON nt.policy_no = t.policy_no
AND nt.endorsement_no = t.endorsement_no
--left join ywglxt.q_auto_agreement_extend_t qe on qe.policy_no = e.policy_no
LEFT JOIN ywglxt.q_auto_agreement_t qt
ON qt.policy_no = e.policy_no
LEFT JOIN datacenter.dc_yangg_qdcode qd
ON qd.code = e.selling_channel_type
LEFT JOIN datacenter.dc_tb_jc_c_tag cl
ON cl. = e.policy_no
LEFT JOIN datacenter.dc_yangg_basecode_teams fg
ON fg.bm = z.department_name
AND fg.ks = y.section_office_name
--left join idst0.t_sell_policy_autobase_t zx on zx.policy_no=e.policy_no
--left join idst0.auto_agreement_extend_t et on et.policy_no = e.policy_no
LEFT JOIN idst0.auto_agreement_extend_t et
ON et.policy_no = e.policy_no
LEFT JOIN idst0.t_sell_policy_autobase_t zx
ON zx.policy_no = e.policy_no
LEFT JOIN datacenter.dc_YZH_ZXYS YS
ON YS. = nvl(zx.workerno,
et.telpartnercode)
--left join v_lsj_dimian dm on dm.vin=v.vin and e.selling_channel_type='25' and dm.MEMO like'%地面续保%'
--left join datacenter.dc_lsj_zx_team zt on zt.name=coalesce(zc.name,zc1.name,bc.name,dm.JBRMC)
WHERE t.signature_date >= to_date('2023-01-01 00:00:00',
'yyyy-mm-dd hh24:mi:ss')
AND t.signature_date < to_date(to_char(SYSDATE - 1,
'yyyy-mm-dd') || ' 23:59:59',
'yyyy-mm-dd hh24:mi:ss')
--and t.endorsement_no = ''
AND e.policy_status = '1' --
AND qt.tflag = '0' --
AND qt.usage_xm = '家庭自用车'
--
--and e.policy_no in ('AXIMC90Y1419B038594J','AXIMC90CTP19B039593R','AXIMC04CTP19B013473X')
AND e.planned_end_date - e.inception_date >= 360
--
)
-----
,
dd2 AS
(SELECT ,
the_year,
the_month,
bm,
bmdm,
,
,
,
N,
N,
CASE
WHEN pdh = '' THEN
tid
END tid,
to_number('1') ,
COUNT(DISTINCT CASE
WHEN pdh = '' THEN
bdh
END) ,
SUM(bf)
FROM (SELECT DISTINCT *
FROM aa) aa
GROUP BY bm,
bmdm,
CASE
WHEN pdh = '' THEN
tid
END,
the_year,
the_month,
BTID,
,
,
,
,
N,
N
UNION
SELECT ,
the_year,
the_month,
bm,
bmdm,
,
,
,
N,
N,
CASE
WHEN btid = tid THEN
''
ELSE
btid
END btid,
to_number('0') ,
to_number('0') ,
to_number('0')
FROM (SELECT DISTINCT *
FROM aa) aa),
DD AS
(SELECT *
FROM DD2
WHERE TID IS NOT NULL)
--select * from dd
,
bb AS
(SELECT DISTINCT q.policy_no bdh,
q.endorsement_no pdh,
qna.t_cre tid,
to_number(to_char(q.signature_date,
'yyyy')) || '' nf,
(to_char(q.signature_date,
'mm')) mm_f,
to_char(q.signature_date,
'dd') || '' dd,
q.signature_date sj,
round((pt.premium_amount - nvl(pt.taxamount,
0)) * c.rate / 100,
2) bf,
z.department_name bm
FROM idst0.nonauto_agreement_request_t q
LEFT JOIN idst0.nonauto_agreement_t e
ON e.policy_no = q.policy_no
LEFT JOIN idst0.nonauto_premium_t pt
ON pt.endorsement_no = q.endorsement_no
AND pt.policy_no = q.policy_no
LEFT JOIN idst0.reinsurance_t r
ON r.reinsurance_policy_no = e.policy_no
LEFT JOIN idst0.exrate_month_t c
ON pt.currency_code = c.bzh
AND to_char(q.signature_date,
'YYYY') = c.theyear
AND to_char(q.signature_date,
'fmmm') = c.themonth
LEFT JOIN idst0.rydm_t x
ON x.staff_code = e.operator_code
LEFT JOIN idst0.ks_t y
ON y.section_office_code = x.section_office_code
LEFT JOIN idst0.bm_t z
ON z.department_code = x.department_code
LEFT JOIN ywglxt.q_nonauto_agreement_t qna
ON qna.policy_no = q.policy_no
LEFT JOIN datacenter.dc_yangg_gkxzh gk
ON gk.product_code = e.product_code --
--left join datacenter.dc_yangg_zbxzh zb on zb.product_code = e.product_code --
LEFT JOIN dd
ON dd.tid = qna.t_cre
WHERE qna.tflag = '0'
AND (CASE
WHEN q.endorsement_no != '' AND
round((pt.premium_amount - nvl(pt.taxamount,
0)) * c.rate / 100,
2) != 0 THEN
''
END) IS NULL
--and q.endorsement_no = ''
AND e.policy_status = '1'
AND gk.product_code IS NOT NULL
AND (e.product_code LIKE '2%' OR e.product_code LIKE '1106%' -- --
OR e.product_code LIKE '1107%' OR e.product_code LIKE '1108%' OR e.product_code LIKE '1307%' OR e.product_code LIKE '1304A400%' --
)
--and e.product_code not in ('22KC9800')
AND q.signature_date >= to_date('2023-01-01 00:00:00',
'yyyy-mm-dd hh24:mi:ss')
AND q.signature_date < to_date(to_char(SYSDATE - 1,
'yyyy-mm-dd') || ' 23:59:59',
'yyyy-mm-dd hh24:mi:ss')
AND e.planned_end_date - e.inception_date >= 90
AND dd.tid IS NOT NULL
--)
)
--SELECT * FROM BB
,
cc AS
(SELECT mm_f,
tid ,
COUNT(DISTINCT bdh) ,
SUM(bf)
FROM bb
GROUP BY tid,
mm_f),
ff AS
(SELECT dd.*,
cc.*
FROM dd
LEFT JOIN cc
ON cc. = dd.tid
AND cc.mm_f = dd.the_month) --OR cc. = dd.btid
--select * from ff
SELECT to_date(,
'yyyy-mm-dd') ,
the_year ,
the_month ,
bm ,
bmdm ,
N,
N,
,
,
,
nvl(SUM(),
0) ,
nvl(SUM(),
0)
FROM ff
WHERE to_date(ff.,
'yyyy-mm-dd') >= DATE '2023-01-01'
AND to_date(ff.,
'yyyy-mm-dd') <= SYSDATE
AND bm IN ('续保业务部',
'湖里支公司')
GROUP BY ,
the_year,
the_month,
bm,
bmdm,
,
,
,
N,
N
ORDER BY ,
;
SELECT *
FROM desktop_archievement_admin.;