Commit c457ed0b authored by 胡涛's avatar 胡涛

指标统计sql脚本

parent 7d6a0dfc
-- ZB_DM_PROVDAYQBBF ZB_DM_分公司今日签单今日起保保费
create table ZB_DM_PROVDAYQBBF(
`key` varchar(256) ,
`hkey` varchar(256),
`val` decimal(18,2),
primary key (`key`)
)
;
\ No newline at end of file
-- ZB_DM_PROVQUARTERYWLYBF ZB_DM_分公司分业务来源季末前起保保费
create table ZB_DM_PROVQUARTERYWLYBF(
`key` varchar(256) ,
`hkey` varchar(256),
`val` decimal(18,2),
primary key (`key`)
)
;
\ No newline at end of file
-- ZB_DM_PROVYWLYBF ZB_DM_分公司分业务来源年底前起保保费
create table ZB_DM_PROVYWLYBF(
`key` varchar(256) ,
`hkey` varchar(256),
`val` decimal(18,2),
primary key (`key`)
)
;
\ No newline at end of file
-- ZB_DM_PROVDAYYWLYBF ZB_DM_分公司分业务来源当日签单当日起保保费
create table ZB_DM_PROVDAYYWLYBF(
`key` varchar(256) ,
`hkey` varchar(256),
`val` decimal(18,2),
primary key (`key`)
)
;
\ No newline at end of file
-- ZB_DM_PROVMONTHYWLYBF ZB_DM_分公司分业务来源月底前起保保费
create table ZB_DM_PROVMONTHYWLYBF(
`key` varchar(256) ,
`hkey` varchar(256),
`val` decimal(18,2),
primary key (`key`)
)
;
\ No newline at end of file
-- ZB_DM_ALLDAYQBBF ZB_DM_总公司今日签单今日起保保费
create table ZB_DM_ALLDAYQBBF(
`key` varchar(256) ,
`val` decimal(18,2),
primary key (`key`)
)
;
\ No newline at end of file
-- ZB_DM_ALLQUARTERYWLYBF ZB_DM_总公司分业务来源季末前起保保费
create table ZB_DM_ALLQUARTERYWLYBF(
`key` varchar(256) ,
`hkey` varchar(256),
`val` decimal(18,2),
primary key (`key`)
)
;
\ No newline at end of file
-- ZB_DM_ALLYWLYBF ZB_DM_总公司分业务来源年底前起保保费
create table ZB_DM_ALLYWLYBF(
`key` varchar(256) ,
`hkey` varchar(256),
`val` decimal(18,2),
primary key (`key`)
)
;
\ No newline at end of file
-- ZB_DM_ALLDAYYWLYBF ZB_DM_总公司分业务来源当日签单当日起保保费
create table ZB_DM_ALLDAYYWLYBF(
`key` varchar(256) ,
`hkey` varchar(256),
`val` decimal(18,2),
primary key (`key`)
)
;
\ No newline at end of file
-- ZB_DM_ALLMONTHYWLYBF ZB_DM_总公司分业务来源月底前起保保费
create table ZB_DM_ALLMONTHYWLYBF(
`key` varchar(256) ,
`hkey` varchar(256),
`val` decimal(18,2),
primary key (`key`)
)
;
\ No newline at end of file
...@@ -17,7 +17,7 @@ SELECT ...@@ -17,7 +17,7 @@ SELECT
from ZB_ODS.ZB_ODS_KAFKA.ZBDATA s1 from ZB_ODS.ZB_ODS_KAFKA.ZBDATA s1
where where
s1.`COMNAME` is not null s1.`COMNAME` is not null
and s1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyy-MM-dd') and s1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
-- 起保时间的年份小于等于今年 -- 起保时间的年份小于等于今年
and left(s1.`startTime`,4) <= DATE_FORMAT(LOCALTIMESTAMP,'yyyy') and left(s1.`startTime`,4) <= DATE_FORMAT(LOCALTIMESTAMP,'yyyy')
group by group by
...@@ -57,3 +57,47 @@ group by ...@@ -57,3 +57,47 @@ group by
s1.`uwConclueDate` s1.`uwConclueDate`
,s1.`LEVEL1COMCODE` ,s1.`LEVEL1COMCODE`
; ;
-- 中支
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVQBBF
select
CONCAT(
'cityqbbf/'
,s1.`uwConclueDate`
) as `key`
,s1.`LEVEL2COMCODE` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_JRQDJNQBBF_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`LEVEL2COMCODE`
;
-- 县支
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVQBBF
select
CONCAT(
'countryqbbf/'
,s1.`uwConclueDate`
) as `key`
,s1.`LEVEL3COMCODE` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_JRQDJNQBBF_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`LEVEL3COMCODE`
;
-- 团队
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVQBBF
select
CONCAT(
'teamqbbf/'
,s1.`uwConclueDate`
) as `key`
,s1.`LEVEL4COMCODE` as `hkey`
,cast(s1.`cost` as DECIMAL(18,2)) as `val`
from VIEW_ZB_DM_JRQDJNQBBF_TUANDUI s1
;
\ No newline at end of file
-- ZB_DM_JRQDJRQBBF ZB_DM_今日签单今日起保保费
-- key:alldayqdbf/日期
-- 1. 保单的时间口径为: 核保时间在今天并且起保时间的日份小于等于今日
-- 2. 批单的时间口径为: 核批通过时间在今天并且核批生效时间的日份小于等于今日。
-- step1:
-- 团队汇总
CREATE TEMPORARY VIEW VIEW_ZB_DM_JRQDJRQBBF_TUANDUI AS
SELECT
s1.`uwConclueDate` as `uwConclueDate`
,s1.`LEVEL1COMCODE` as `LEVEL1COMCODE`
,s1.`LEVEL2COMCODE` as `LEVEL2COMCODE`
,s1.`LEVEL3COMCODE` as `LEVEL3COMCODE`
,s1.`LEVEL4COMCODE` as `LEVEL4COMCODE`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `cost`
from ZB_ODS.ZB_ODS_KAFKA.ZBDATA s1
where
s1.`COMNAME` is not null
and s1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
-- 起保时间的日份小于等于今日
and left(s1.`startTime`,8) <= DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
group by
s1.`uwConclueDate`
,s1.`LEVEL1COMCODE`
,s1.`LEVEL2COMCODE`
,s1.`LEVEL3COMCODE`
,s1.`LEVEL4COMCODE`
;
-- 总公司
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_ALLDAYQBBF
select
CONCAT(
'alldayqdbf/'
,s1.`uwConclueDate`
) as `key`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_JRQDJRQBBF_TUANDUI s1
group by
s1.`uwConclueDate`
;
-- 分公司
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVDAYQBBF
select
CONCAT(
'provdayqdbf/'
,s1.`uwConclueDate`
) as `key`
,s1.`LEVEL1COMCODE` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_JRQDJRQBBF_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`LEVEL1COMCODE`
;
-- 中支
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVDAYQBBF
select
CONCAT(
'citydayqdbf/'
,s1.`uwConclueDate`
) as `key`
,s1.`LEVEL2COMCODE` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_JRQDJRQBBF_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`LEVEL2COMCODE`
;
-- 县支
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVDAYQBBF
select
CONCAT(
'countrydayqdbf/'
,s1.`uwConclueDate`
) as `key`
,s1.`LEVEL3COMCODE` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_JRQDJRQBBF_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`LEVEL3COMCODE`
;
-- 团队
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVDAYQBBF
select
CONCAT(
'teamdayqdbf/'
,s1.`uwConclueDate`
) as `key`
,s1.`LEVEL4COMCODE` as `hkey`
,cast(s1.`cost` as DECIMAL(18,2)) as `val`
from VIEW_ZB_DM_JRQDJRQBBF_TUANDUI s1
;
...@@ -17,7 +17,7 @@ SELECT ...@@ -17,7 +17,7 @@ SELECT
from ZB_ODS.ZB_ODS_KAFKA.ZBDATA s1 from ZB_ODS.ZB_ODS_KAFKA.ZBDATA s1
where where
s1.`COMNAME` is not null s1.`COMNAME` is not null
and s1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyy-MM-dd') and s1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
group by group by
s1.`uwConclueDate` s1.`uwConclueDate`
,s1.`LEVEL1COMCODE` ,s1.`LEVEL1COMCODE`
...@@ -55,3 +55,44 @@ group by ...@@ -55,3 +55,44 @@ group by
; ;
-- 中支
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVQDBF
select
CONCAT(
'cityqdbf/'
,s1.`uwConclueDate`
) as `key`
,s1.`LEVEL2COMCODE` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_JRQDBF_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`LEVEL2COMCODE`
;
-- 县支
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVQDBF
select
CONCAT(
'countryqdbf/'
,s1.`uwConclueDate`
) as `key`
,s1.`LEVEL3COMCODE` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_JRQDBF_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`LEVEL3COMCODE`
;
-- 团队
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVQDBF
select
CONCAT(
'teamqdbf/'
,s1.`uwConclueDate`
) as `key`
,s1.`LEVEL4COMCODE` as `hkey`
,cast(s1.`cost` as DECIMAL(18,2)) as `val`
from VIEW_ZB_DM_JRQDBF_TUANDUI s1
;
\ No newline at end of file
...@@ -17,9 +17,9 @@ SELECT ...@@ -17,9 +17,9 @@ SELECT
from ZB_ODS.ZB_ODS_KAFKA.ZBDATA s1 from ZB_ODS.ZB_ODS_KAFKA.ZBDATA s1
where where
s1.`COMNAME` is not null s1.`COMNAME` is not null
and s1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyy-MM-dd') and s1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
-- 核保时间在今天并且起保时间的月份小于等于当月。 -- 核保时间在今天并且起保时间的月份小于等于当月。
and left(s1.`startTime`,7) <= DATE_FORMAT(LOCALTIMESTAMP,'yyyy-MM') and left(s1.`startTime`,6) <= DATE_FORMAT(LOCALTIMESTAMP,'yyyyMM')
group by group by
s1.`uwConclueDate` s1.`uwConclueDate`
,s1.`LEVEL1COMCODE` ,s1.`LEVEL1COMCODE`
...@@ -57,6 +57,50 @@ group by ...@@ -57,6 +57,50 @@ group by
,s1.`LEVEL1COMCODE` ,s1.`LEVEL1COMCODE`
; ;
-- 中支
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVMONTHQBBF
select
CONCAT(
'citymonthqbbf/'
,s1.`uwConclueDate`
) as `key`
,s1.`LEVEL2COMCODE` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_JRQDYDQQBBF_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`LEVEL2COMCODE`
;
-- 县支
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVMONTHQBBF
select
CONCAT(
'countrymonthqbbf/'
,s1.`uwConclueDate`
) as `key`
,s1.`LEVEL3COMCODE` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_JRQDYDQQBBF_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`LEVEL3COMCODE`
;
-- 团队
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVMONTHQBBF
select
CONCAT(
'teammonthqbbf/'
,s1.`uwConclueDate`
) as `key`
,s1.`LEVEL1COMCODE` as `hkey`
,cast(s1.`cost` as DECIMAL(18,2)) as `val`
from VIEW_ZB_DM_JRQDYDQQBBF_TUANDUI s1
;
......
-- ZB_DM_FYWLYBFJMQQB ZB_DM_分业务来源季末前起保保费
-- key:allquarterywlybf/日期
-- 1. 保单的时间口径为: 核保时间在今天并且起保时间的季度小于等于季度。
-- 2. 批单的时间口径为: 核批通过时间在今天并且核批生效时间的季度小于等于当前季度。
-- step1:
-- 团队汇总
CREATE TEMPORARY VIEW VIEW_ZB_DM_FYWLYBFJMQQB_TUANDUI AS
SELECT
s1.`uwConclueDate` as `uwConclueDate`
,s1.`businessNatureCode` as `businessNatureCode`
,s1.`LEVEL1COMCODE` as `LEVEL1COMCODE`
,s1.`LEVEL2COMCODE` as `LEVEL2COMCODE`
,s1.`LEVEL3COMCODE` as `LEVEL3COMCODE`
,s1.`LEVEL4COMCODE` as `LEVEL4COMCODE`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `cost`
from ZB_ODS.ZB_ODS_KAFKA.ZBDATA s1
where
s1.`COMNAME` is not null
and s1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
-- 起保时间的季度小于等于当前季度
and CASE WHEN DATE_FORMAT(LOCALTIMESTAMP,'MM') in ('01','02','03') THEN left(s1.`startTime`,6) <= CONCAT(DATE_FORMAT(LOCALTIMESTAMP,'yyyy'),'03')
WHEN DATE_FORMAT(LOCALTIMESTAMP,'MM') in ('04','05','06') THEN left(s1.`startTime`,6) <= CONCAT(DATE_FORMAT(LOCALTIMESTAMP,'yyyy'),'06')
WHEN DATE_FORMAT(LOCALTIMESTAMP,'MM') in ('07','08','09') THEN left(s1.`startTime`,6) <= CONCAT(DATE_FORMAT(LOCALTIMESTAMP,'yyyy'),'09')
WHEN DATE_FORMAT(LOCALTIMESTAMP,'MM') in ('10','11','12') THEN left(s1.`startTime`,6) <= CONCAT(DATE_FORMAT(LOCALTIMESTAMP,'yyyy'),'12')
END
group by
s1.`uwConclueDate`
,s1.`businessNatureCode`
,s1.`LEVEL1COMCODE`
,s1.`LEVEL2COMCODE`
,s1.`LEVEL3COMCODE`
,s1.`LEVEL4COMCODE`
;
-- 总公司
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_ALLQUARTERYWLYBF
select
CONCAT(
'allquarterywlybf/'
,s1.`uwConclueDate`
) as `key`
,s1.`businessNatureCode` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_FYWLYBFJMQQB_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`businessNatureCode`
;
-- 分公司
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVQUARTERYWLYBF
select
CONCAT(
'provquarterywlybf/'
,s1.`uwConclueDate`
,'/'
,s1.`LEVEL1COMCODE`
) as `key`
,s1.`businessNatureCode` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_FYWLYBFJMQQB_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`businessNatureCode`
,s1.`LEVEL1COMCODE`
;
-- 中支
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVQUARTERYWLYBF
select
CONCAT(
'cityquarterywlybf/'
,s1.`uwConclueDate`
,'/'
,s1.`LEVEL2COMCODE`
) as `key`
,s1.`businessNatureCode` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_FYWLYBFJMQQB_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`businessNatureCode`
,s1.`LEVEL2COMCODE`
;
-- 县支
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVQUARTERYWLYBF
select
CONCAT(
'countryquarterywlybf/'
,s1.`uwConclueDate`
,'/'
,s1.`LEVEL3COMCODE`
) as `key`
,s1.`businessNatureCode` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_FYWLYBFJMQQB_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`businessNatureCode`
,s1.`LEVEL3COMCODE`
;
-- 团队
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVQUARTERYWLYBF
select
CONCAT(
'teamquarterywlybf/'
,s1.`uwConclueDate`
,'/'
,s1.`LEVEL4COMCODE`
) as `key`
,s1.`businessNatureCode` as `hkey`
,cast(s1.`cost` as DECIMAL(18,2)) as `val`
from VIEW_ZB_DM_FYWLYBFJMQQB_TUANDUI s1
;
\ No newline at end of file
-- ZB_DM_FYWLYBFNDQQB ZB_DM_分业务来源年底前起保保费
-- key:allywlybf/日期
-- 1. 保单的时间口径为: 核保时间在今天并且起保时间的年份小于等于今年
-- 2. 批单的时间口径为: 核批通过时间在今天并且核批生效时间的年份小于等于今年。
-- step1:
-- 团队汇总
CREATE TEMPORARY VIEW VIEW_ZB_DM_FYWLYBFNDQQB_TUANDUI AS
SELECT
s1.`uwConclueDate` as `uwConclueDate`
,s1.`businessNatureCode` as `businessNatureCode`
,s1.`LEVEL1COMCODE` as `LEVEL1COMCODE`
,s1.`LEVEL2COMCODE` as `LEVEL2COMCODE`
,s1.`LEVEL3COMCODE` as `LEVEL3COMCODE`
,s1.`LEVEL4COMCODE` as `LEVEL4COMCODE`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `cost`
from ZB_ODS.ZB_ODS_KAFKA.ZBDATA s1
where
s1.`COMNAME` is not null
and s1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
-- 起保时间的年份小于等于当年
and left(s1.`startTime`,4) <= DATE_FORMAT(LOCALTIMESTAMP,'yyyy')
group by
s1.`uwConclueDate`
,s1.`businessNatureCode`
,s1.`LEVEL1COMCODE`
,s1.`LEVEL2COMCODE`
,s1.`LEVEL3COMCODE`
,s1.`LEVEL4COMCODE`
;
-- 总公司
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_ALLYWLYBF
select
CONCAT(
'allywlybf/'
,s1.`uwConclueDate`
) as `key`
,s1.`businessNatureCode` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_FYWLYBFNDQQB_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`businessNatureCode`
;
-- 分公司
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVYWLYBF
select
CONCAT(
'provywlybf/'
,s1.`uwConclueDate`
,'/'
,s1.`LEVEL1COMCODE`
) as `key`
,s1.`businessNatureCode` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_FYWLYBFNDQQB_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`businessNatureCode`
,s1.`LEVEL1COMCODE`
;
-- 中支
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVYWLYBF
select
CONCAT(
'cityywlybf/'
,s1.`uwConclueDate`
,'/'
,s1.`LEVEL2COMCODE`
) as `key`
,s1.`businessNatureCode` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_FYWLYBFNDQQB_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`businessNatureCode`
,s1.`LEVEL2COMCODE`
;
-- 县支
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVYWLYBF
select
CONCAT(
'countryywlybf/'
,s1.`uwConclueDate`
,'/'
,s1.`LEVEL3COMCODE`
) as `key`
,s1.`businessNatureCode` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_FYWLYBFNDQQB_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`businessNatureCode`
,s1.`LEVEL3COMCODE`
;
-- 团队
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVYWLYBF
select
CONCAT(
'teamywlybf/'
,s1.`uwConclueDate`
,'/'
,s1.`LEVEL4COMCODE`
) as `key`
,s1.`businessNatureCode` as `hkey`
,cast(s1.`cost` as DECIMAL(18,2)) as `val`
from VIEW_ZB_DM_FYWLYBFNDQQB_TUANDUI s1
;
\ No newline at end of file
-- ZB_DM_FYWLYBFDRQDDRQB ZB_DM_分业务来源当日签单当日起保保费
-- key:alldayywlybf/日期
-- 1. 保单的时间口径为: 核保时间在今天并且起保时间的日份小于等于今日
-- 2. 批单的时间口径为: 核批通过时间在今天并且核批生效时间的日份小于等于今日。
-- step1:
-- 团队汇总
CREATE TEMPORARY VIEW VIEW_ZB_DM_FYWLYBFDRQDDRQB_TUANDUI AS
SELECT
s1.`uwConclueDate` as `uwConclueDate`
,s1.`businessNatureCode` as `businessNatureCode`
,s1.`LEVEL1COMCODE` as `LEVEL1COMCODE`
,s1.`LEVEL2COMCODE` as `LEVEL2COMCODE`
,s1.`LEVEL3COMCODE` as `LEVEL3COMCODE`
,s1.`LEVEL4COMCODE` as `LEVEL4COMCODE`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `cost`
from ZB_ODS.ZB_ODS_KAFKA.ZBDATA s1
where
s1.`COMNAME` is not null
and s1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
-- 起保时间的日份小于等于今日
and left(s1.`startTime`,8) <= DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
group by
s1.`uwConclueDate`
,s1.`businessNatureCode`
,s1.`LEVEL1COMCODE`
,s1.`LEVEL2COMCODE`
,s1.`LEVEL3COMCODE`
,s1.`LEVEL4COMCODE`
;
-- 总公司
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_ALLDAYYWLYBF
select
CONCAT(
'alldayywlybf/'
,s1.`uwConclueDate`
) as `key`
,s1.`businessNatureCode` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_FYWLYBFDRQDDRQB_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`businessNatureCode`
;
-- 分公司
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVDAYYWLYBF
select
CONCAT(
'provdayywlybf/'
,s1.`uwConclueDate`
,'/'
,s1.`LEVEL1COMCODE`
) as `key`
,s1.`businessNatureCode` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_FYWLYBFDRQDDRQB_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`businessNatureCode`
,s1.`LEVEL1COMCODE`
;
-- 中支
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVDAYYWLYBF
select
CONCAT(
'citydayywlybf/'
,s1.`uwConclueDate`
,'/'
,s1.`LEVEL2COMCODE`
) as `key`
,s1.`businessNatureCode` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_FYWLYBFDRQDDRQB_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`businessNatureCode`
,s1.`LEVEL2COMCODE`
;
-- 县支
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVDAYYWLYBF
select
CONCAT(
'countrydayywlybf/'
,s1.`uwConclueDate`
,'/'
,s1.`LEVEL3COMCODE`
) as `key`
,s1.`businessNatureCode` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_FYWLYBFDRQDDRQB_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`businessNatureCode`
,s1.`LEVEL3COMCODE`
;
-- 团队
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVDAYYWLYBF
select
CONCAT(
'teamdayywlybf/'
,s1.`uwConclueDate`
,'/'
,s1.`LEVEL4COMCODE`
) as `key`
,s1.`businessNatureCode` as `hkey`
,cast(s1.`cost` as DECIMAL(18,2)) as `val`
from VIEW_ZB_DM_FYWLYBFDRQDDRQB_TUANDUI s1
;
\ No newline at end of file
-- ZB_DM_FYWLYBFYDQQB ZB_DM_分业务来源月底前起保保费
-- key:allmonthywlybf/日期
-- 1. 保单的时间口径为: 核保时间在今天并且起保时间的月份小于等于当月。
-- 2. 批单的时间口径为: 核批通过时间在今天并且核批生效时间的月份小于等于当月。
-- step1:
-- 团队汇总
CREATE TEMPORARY VIEW VIEW_ZB_DM_FYWLYBFYDQQB_TUANDUI AS
SELECT
s1.`uwConclueDate` as `uwConclueDate`
,s1.`businessNatureCode` as `businessNatureCode`
,s1.`LEVEL1COMCODE` as `LEVEL1COMCODE`
,s1.`LEVEL2COMCODE` as `LEVEL2COMCODE`
,s1.`LEVEL3COMCODE` as `LEVEL3COMCODE`
,s1.`LEVEL4COMCODE` as `LEVEL4COMCODE`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `cost`
from ZB_ODS.ZB_ODS_KAFKA.ZBDATA s1
where
s1.`COMNAME` is not null
and s1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
-- 起保时间的月份小于等于当月
and left(s1.`startTime`,6) <= DATE_FORMAT(LOCALTIMESTAMP,'yyyyMM')
group by
s1.`uwConclueDate`
,s1.`businessNatureCode`
,s1.`LEVEL1COMCODE`
,s1.`LEVEL2COMCODE`
,s1.`LEVEL3COMCODE`
,s1.`LEVEL4COMCODE`
;
-- 总公司
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_ALLMONTHYWLYBF
select
CONCAT(
'allmonthywlybf/'
,s1.`uwConclueDate`
) as `key`
,s1.`businessNatureCode` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_FYWLYBFYDQQB_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`businessNatureCode`
;
-- 分公司
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVMONTHYWLYBF
select
CONCAT(
'provmonthywlybf/'
,s1.`uwConclueDate`
,'/'
,s1.`LEVEL1COMCODE`
) as `key`
,s1.`businessNatureCode` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_FYWLYBFYDQQB_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`businessNatureCode`
,s1.`LEVEL1COMCODE`
;
-- 中支
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVMONTHYWLYBF
select
CONCAT(
'citymonthywlybf/'
,s1.`uwConclueDate`
,'/'
,s1.`LEVEL2COMCODE`
) as `key`
,s1.`businessNatureCode` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_FYWLYBFYDQQB_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`businessNatureCode`
,s1.`LEVEL2COMCODE`
;
-- 县支
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVMONTHYWLYBF
select
CONCAT(
'countrymonthywlybf/'
,s1.`uwConclueDate`
,'/'
,s1.`LEVEL3COMCODE`
) as `key`
,s1.`businessNatureCode` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_FYWLYBFYDQQB_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`businessNatureCode`
,s1.`LEVEL3COMCODE`
;
-- 团队
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVMONTHYWLYBF
select
CONCAT(
'teammonthywlybf/'
,s1.`uwConclueDate`
,'/'
,s1.`LEVEL4COMCODE`
) as `key`
,s1.`businessNatureCode` as `hkey`
,cast(s1.`cost` as DECIMAL(18,2)) as `val`
from VIEW_ZB_DM_FYWLYBFYDQQB_TUANDUI s1
;
\ No newline at end of file
...@@ -17,7 +17,7 @@ SELECT ...@@ -17,7 +17,7 @@ SELECT
from ZB_ODS.ZB_ODS_KAFKA.ZBDATA s1 from ZB_ODS.ZB_ODS_KAFKA.ZBDATA s1
where where
s1.`COMNAME` is not null s1.`COMNAME` is not null
and s1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyy-MM-dd') and s1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
-- 起保时间的年份小于等于今年 -- 起保时间的年份小于等于今年
and left(s1.`startTime`,4) <= DATE_FORMAT(LOCALTIMESTAMP,'yyyy') and left(s1.`startTime`,4) <= DATE_FORMAT(LOCALTIMESTAMP,'yyyy')
group by group by
...@@ -63,3 +63,55 @@ group by ...@@ -63,3 +63,55 @@ group by
,s1.`chnl` ,s1.`chnl`
,s1.`LEVEL1COMCODE` ,s1.`LEVEL1COMCODE`
; ;
-- 中支
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_CHNLBF_FEN
select
CONCAT(
'citychnlbf/'
,s1.`uwConclueDate`
,'/',s1.`LEVEL2COMCODE`
) as `key`
,s1.`chnl` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_FQDBF_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`chnl`
,s1.`LEVEL2COMCODE`
;
-- 县支
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_CHNLBF_FEN
select
CONCAT(
'countrychnlbf/'
,s1.`uwConclueDate`
,'/',s1.`LEVEL3COMCODE`
) as `key`
,s1.`chnl` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_FQDBF_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`chnl`
,s1.`LEVEL3COMCODE`
;
-- 团队
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_CHNLBF_FEN
select
CONCAT(
'teamchnlbf/'
,s1.`uwConclueDate`
,'/',s1.`LEVEL4COMCODE`
) as `key`
,s1.`chnl` as `hkey`
,cast(s1.`cost` as DECIMAL(18,2)) as `val`
from VIEW_ZB_DM_FQDBF_TUANDUI s1
;
\ No newline at end of file
...@@ -18,7 +18,7 @@ SELECT ...@@ -18,7 +18,7 @@ SELECT
from ZB_ODS.ZB_ODS_KAFKA.ZBDATA s1 from ZB_ODS.ZB_ODS_KAFKA.ZBDATA s1
where where
s1.`COMNAME` is not null s1.`COMNAME` is not null
and s1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyy-MM-dd') and s1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
-- 起保时间的年份小于等于今年 -- 起保时间的年份小于等于今年
and left(s1.`startTime`,4) <= DATE_FORMAT(LOCALTIMESTAMP,'yyyy') and left(s1.`startTime`,4) <= DATE_FORMAT(LOCALTIMESTAMP,'yyyy')
group by group by
...@@ -30,6 +30,7 @@ group by ...@@ -30,6 +30,7 @@ group by
,s1.`LEVEL4COMCODE` ,s1.`LEVEL4COMCODE`
; ;
--总公司
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_ALLXLBF insert into ZB_DM.ZB_DM_REDIS.ZB_DM_ALLXLBF
select select
CONCAT( CONCAT(
...@@ -60,5 +61,51 @@ group by ...@@ -60,5 +61,51 @@ group by
s1.`uwConclueDate` s1.`uwConclueDate`
,s1.`risk` ,s1.`risk`
,s1.`LEVEL1COMCODE` ,s1.`LEVEL1COMCODE`
;
-- 中支
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVXLBF
select
CONCAT(
'cityxlbf/'
,s1.`uwConclueDate`
,'/',s1.`LEVEL2COMCODE`
) as `key`
,s1.`risk` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_FXLBF_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`risk`
,s1.`LEVEL2COMCODE`
;
-- 县支
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVXLBF
select
CONCAT(
'countryxlbf/'
,s1.`uwConclueDate`
,'/',s1.`LEVEL3COMCODE`
) as `key`
,s1.`risk` as `hkey`
,sum(cast(s1.`cost` as DECIMAL(18,2))) as `val`
from VIEW_ZB_DM_FXLBF_TUANDUI s1
group by
s1.`uwConclueDate`
,s1.`risk`
,s1.`LEVEL3COMCODE`
;
-- 团队
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_PROVXLBF
select
CONCAT(
'teamxlbf/'
,s1.`uwConclueDate`
,'/',s1.`LEVEL4COMCODE`
) as `key`
,s1.`risk` as `hkey`
,cast(s1.`cost` as DECIMAL(18,2)) as `val`
from VIEW_ZB_DM_FXLBF_TUANDUI s1
; ;
\ No newline at end of file
...@@ -39,7 +39,7 @@ from ( ...@@ -39,7 +39,7 @@ from (
from ZB_ODS.ZB_ODS_KAFKA.ZBDATA d1 from ZB_ODS.ZB_ODS_KAFKA.ZBDATA d1
where where
d1.`COMNAME` is not null d1.`COMNAME` is not null
and d1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyy-MM-dd') and d1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
and LEFT(d1.`risk`,2) = '05' and LEFT(d1.`risk`,2) = '05'
) c1 ) c1
where c1.rownum <= 20 where c1.rownum <= 20
...@@ -49,8 +49,6 @@ from ( ...@@ -49,8 +49,6 @@ from (
) s1 ) s1
group by group by
s1.`uwConclueDate` s1.`uwConclueDate`
; ;
...@@ -94,7 +92,7 @@ from ( ...@@ -94,7 +92,7 @@ from (
from ZB_ODS.ZB_ODS_KAFKA.ZBDATA d1 from ZB_ODS.ZB_ODS_KAFKA.ZBDATA d1
where where
d1.`COMNAME` is not null d1.`COMNAME` is not null
and d1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyy-MM-dd') and d1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
and LEFT(d1.`risk`,2) = '05' and LEFT(d1.`risk`,2) = '05'
) c1 ) c1
where c1.rownum <= 20 where c1.rownum <= 20
...@@ -105,7 +103,57 @@ from ( ...@@ -105,7 +103,57 @@ from (
group by group by
s1.`uwConclueDate` s1.`uwConclueDate`
,s1.`group_com` ,s1.`group_com`
;
-- 中支
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_BIGCCITYBD
select
CONCAT(
'bigccountrybd/'
,s1.`uwConclueDate`
,'/',s1.`group_com`
) as `key`
,CastToJsonArrayUDF(
listagg(concat(
'com' ,':' ,`com` ,','
,'comname' ,':' ,`comname` ,','
,'risk' ,':' ,`risk` ,','
,'riskname' ,':' ,`riskname` ,','
,'chnl' ,':' ,`chnl` ,','
,'chnlname' ,':' ,`chnlname` ,','
,'cost' ,':' ,`cost` ,','
,'no' ,':' ,`no`
),';')
) as `val`
from (
select
*
from (
select
d1.`uwConclueDate` as `uwConclueDate`
,d1.`LEVEL2COMCODE` as `group_com`
,d1.`LEVEL3COMCODE` as `com`
,d1.`LEVEL3COMDESC` as `comname`
,d1.`risk` as `risk`
,d1.`riskname` as `riskname`
,d1.`chnl` as `chnl`
,d1.`chnlname` as `chnlname`
,d1.`cost` as `cost`
,d1.`no` as `no`
,ROW_NUMBER() OVER(PARTITION BY d1.`LEVEL2COMCODE`,d1.`uwConclueDate` ORDER BY d1.`cost` DESC) as rownum
from ZB_ODS.ZB_ODS_KAFKA.ZBDATA d1
where d1.`COMNAME` is not null
and d1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
and LEFT(d1.`risk`,2) = '05'
) c1
where c1.rownum <= 20
ORDER by
c1.`cost`
asc
) s1
group by
s1.`uwConclueDate`
,s1.`group_com`
; ;
...@@ -39,7 +39,7 @@ from ( ...@@ -39,7 +39,7 @@ from (
from ZB_ODS.ZB_ODS_KAFKA.ZBDATA d1 from ZB_ODS.ZB_ODS_KAFKA.ZBDATA d1
where where
d1.`COMNAME` is not null d1.`COMNAME` is not null
and d1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyy-MM-dd') and d1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
and LEFT(d1.`risk`,2) <> '05' and LEFT(d1.`risk`,2) <> '05'
) c1 ) c1
where c1.rownum <= 20 where c1.rownum <= 20
...@@ -49,9 +49,7 @@ from ( ...@@ -49,9 +49,7 @@ from (
) s1 ) s1
group by group by
s1.`uwConclueDate` s1.`uwConclueDate`
;;
;
-- 分公司 -- 分公司
insert into ZB_DM.ZB_DM_REDIS.ZB_DM_BIGFCCITYBD insert into ZB_DM.ZB_DM_REDIS.ZB_DM_BIGFCCITYBD
...@@ -92,7 +90,7 @@ from ( ...@@ -92,7 +90,7 @@ from (
from ZB_ODS.ZB_ODS_KAFKA.ZBDATA d1 from ZB_ODS.ZB_ODS_KAFKA.ZBDATA d1
where where
d1.`COMNAME` is not null d1.`COMNAME` is not null
and d1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyy-MM-dd') and d1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
and LEFT(d1.`risk`,2) <> '05' and LEFT(d1.`risk`,2) <> '05'
) c1 ) c1
where c1.rownum <= 20 where c1.rownum <= 20
...@@ -103,5 +101,55 @@ from ( ...@@ -103,5 +101,55 @@ from (
group by group by
s1.`uwConclueDate` s1.`uwConclueDate`
,s1.`group_com` ,s1.`group_com`
;;
; -- 中支
\ No newline at end of file insert into ZB_DM.ZB_DM_REDIS.ZB_DM_BIGFCCITYBD
select
CONCAT(
'bigfccountrybd/'
,s1.`uwConclueDate`
,'/',s1.`group_com`
) as `key`
,CastToJsonArrayUDF(
listagg(concat(
'com' ,':' ,`com` ,','
,'comname' ,':' ,`comname` ,','
,'risk' ,':' ,`risk` ,','
,'riskname' ,':' ,`riskname` ,','
,'chnl' ,':' ,`chnl` ,','
,'chnlname' ,':' ,`chnlname` ,','
,'cost' ,':' ,`cost` ,','
,'no' ,':' ,`no`
),';')
) as `val`
from (
select
*
from(
select d1.`uwConclueDate` as `uwConclueDate`
,d1.`LEVEL2COMCODE` as `group_com`
,d1.`LEVEL3COMCODE` as `com`
,d1.`LEVEL3COMDESC` as `comname`
,d1.`risk` as `risk`
,d1.`riskname` as `riskname`
,d1.`chnl` as `chnl`
,d1.`chnlname` as `chnlname`
,d1.`cost` as `cost`
,d1.`no` as `no`
,ROW_NUMBER() OVER(PARTITION BY d1.`LEVEL2COMCODE`,d1.`uwConclueDate` ORDER BY d1.`cost` DESC) as rownum
from ZB_ODS.ZB_ODS_KAFKA.ZBDATA d1
where d1.`COMNAME` is not null
and d1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
and LEFT(d1.`risk`,2) <> '05'
) c1
where c1.rownum <= 20
ORDER by
c1.`cost`
asc
) s1
group by
s1.`uwConclueDate`
,s1.`group_com`
;;
\ No newline at end of file
...@@ -18,8 +18,9 @@ create table ZBDATA( ...@@ -18,8 +18,9 @@ create table ZBDATA(
`riskname` String ,-- 险种代码名称 `riskname` String ,-- 险种代码名称
`chnl` String ,-- 业务渠道 `chnl` String ,-- 业务渠道
`chnlname` String ,-- 业务渠道名称 `chnlname` String ,-- 业务渠道名称
`businessNatureCode` String ,-- 业务来源
`businessNatureName` String ,-- 业务来源名称
`cost` String ,-- 含税保费 `cost` String ,-- 含税保费
`no` String -- 保单号 `no` String -- 保单号
) )
; ;
\ No newline at end of file
...@@ -19,16 +19,19 @@ select ...@@ -19,16 +19,19 @@ select
,e1.productCode as `risk` ,e1.productCode as `risk`
,t3.RISKNAME as `riskname` ,t3.RISKNAME as `riskname`
,e1.businessChannelCode as `chnl` ,e1.businessChannelCode as `chnl`
,e1.businessNatureCode as `businessNatureCode`
,t4.CODEDESC as `businessNatureName`
,t2.NEWCHNLTYPEDESC as `chnlname` ,t2.NEWCHNLTYPEDESC as `chnlname`
,e1.premium as `cost` ,e1.premium as `cost`
,e1.policyNo as `no` ,e1.policyNo as `no`
from ( from (
select select
LongTimeToStringUDF(uwConclueDate,'yyyy-MM-dd') as uwConclueDate -- 核保通过时间 LongTimeToStringUDF(uwConclueDate,'yyyyMMdd') as uwConclueDate -- 核保通过时间
,LongTimeToStringUDF(startTime,'yyyy-MM-dd') as startTime -- 起保时间 ,LongTimeToStringUDF(startTime,'yyyyMMdd') as startTime -- 起保时间
,businessOffice as businessOffice -- 保单归属机构代码 ,businessOffice as businessOffice -- 保单归属机构代码
,productCode as productCode -- 险种代码 ,productCode as productCode -- 险种代码
,businessChannelCode as businessChannelCode -- 业务渠道 ,businessChannelCode as businessChannelCode -- 业务渠道
,businessNatureCode as businessNatureCode -- 业务来源
,premium as premium -- 含税保费 ,premium as premium -- 含税保费
,policyNo as policyNo -- 保单号 ,policyNo as policyNo -- 保单号
,'bd' as flag -- 保单或批单标记 ,'bd' as flag -- 保单或批单标记
...@@ -36,11 +39,12 @@ from ( ...@@ -36,11 +39,12 @@ from (
from ZB_ODS.ZB_SOURCE_RMQ_POLICY_SIT.POLICY from ZB_ODS.ZB_SOURCE_RMQ_POLICY_SIT.POLICY
union all union all
select select
LongTimeToStringUDF(uwConclueDate,'yyyy-MM-dd') as uwConclueDate -- 核保通过时间 LongTimeToStringUDF(uwConclueDate,'yyyyMMdd') as uwConclueDate -- 核保通过时间
,LongTimeToStringUDF(endorseEffectiveTime,'yyyy-MM-dd')as startTime -- 起保时间 ,LongTimeToStringUDF(endorseEffectiveTime,'yyyyMMdd')as startTime -- 起保时间
,businessOffice as businessOffice -- 保单归属机构代码 ,businessOffice as businessOffice -- 保单归属机构代码
,productCode as productCode -- 险种代码 ,productCode as productCode -- 险种代码
,businessChannelCode as businessChannelCode -- 业务渠道 ,businessChannelCode as businessChannelCode -- 业务渠道
,businessNatureCode as businessNatureCode -- 业务来源
,plpEndorse.staCurNetPremiumVariation as premium -- 含税保费 ,plpEndorse.staCurNetPremiumVariation as premium -- 含税保费
,endorseNo as policyNo -- 保单号 ,endorseNo as policyNo -- 保单号
,'pd' as flag -- 保单或批单标记 ,'pd' as flag -- 保单或批单标记
...@@ -50,7 +54,7 @@ from ( ...@@ -50,7 +54,7 @@ from (
left join ZB_ODS.ZB_ODS_MYSQL.CD_COM_ALL for system_time as of e1.proctime as t1 on e1.businessOffice = t1.COMCODE left join ZB_ODS.ZB_ODS_MYSQL.CD_COM_ALL for system_time as of e1.proctime as t1 on e1.businessOffice = t1.COMCODE
left join ZB_ODS.ZB_ODS_MYSQL.CD_NEWCHNLTYPE for system_time as of e1.proctime as t2 on e1.businessChannelCode = t2.NEWCHNLTYPE left join ZB_ODS.ZB_ODS_MYSQL.CD_NEWCHNLTYPE for system_time as of e1.proctime as t2 on e1.businessChannelCode = t2.NEWCHNLTYPE
left join ZB_ODS.ZB_ODS_MYSQL.CD_REALTIME_RISK for system_time as of e1.proctime as t3 on e1.productCode = t3.RISKCODE left join ZB_ODS.ZB_ODS_MYSQL.CD_REALTIME_RISK for system_time as of e1.proctime as t3 on e1.productCode = t3.RISKCODE
left join ZB_ODS.ZB_ODS_MYSQL.CD_BUSINESSNATURE for system_time as of e1.proctime as t4 on e1.businessNatureCode = t4.CODE
; ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment