Commit 65f446ea authored by 王东's avatar 王东

指标计算承保字段调整

parent 796681e1
...@@ -3,16 +3,40 @@ ...@@ -3,16 +3,40 @@
-- step1: -- step1:
-- 团队汇总 -- 团队汇总
CREATE TEMPORARY VIEW VIEW_ZB_DM_JRQDBF_HB_TUANDUI AS CREATE TEMPORARY VIEW VIEW_ZB_DM_JRQDBF_HB_TUANDUI AS
SELECT select
s1.`uwConclueDate` as `uwConclueDate` a1.`uwConclueDate`
, s1.`LEVEL1COMCODE` as `LEVEL1COMCODE` ,a1.`LEVEL1COMCODE`
, s1.`LEVEL2COMCODE` as `LEVEL2COMCODE` ,a1.`LEVEL2COMCODE`
, s1.`LEVEL3COMCODE` as `LEVEL3COMCODE` ,a1.`LEVEL3COMCODE`
, s1.`LEVEL4COMCODE` as `LEVEL4COMCODE` ,a1.`LEVEL4COMCODE`
, s1.`startTime` as `startTime` ,a1.`startTime`
, s1.`risk` as `risk` ,a1.`risk`
, sum(cast(s1.`cost` as DECIMAL(18, 2)) + if(t1.`cost` is null,0, cast(t1.`cost` as DECIMAL(18, 2)))) as `cost` ,a1.`cost` + if(t1.cost is null ,0,cast(t1.cost as decimal(18,2)))
from ZB_ODS.ZB_ODS_KAFKA.CBDATA s1 from (
SELECT
s1.`uwConclueDate` as `uwConclueDate`
, s1.`LEVEL1COMCODE` as `LEVEL1COMCODE`
, s1.`LEVEL2COMCODE` as `LEVEL2COMCODE`
, s1.`LEVEL3COMCODE` as `LEVEL3COMCODE`
, s1.`LEVEL4COMCODE` as `LEVEL4COMCODE`
, s1.`startTime` as `startTime`
, s1.`risk` as `risk`
, sum(cast(s1.`cost` as DECIMAL(18, 2))) as `cost`
, max(s1.proctime) as proctime
from ZB_ODS.ZB_ODS_KAFKA.CBDATA s1
where
s1.`COMNAME` is not null
and s1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
and LongTimeToStringUDF(s1.log_time,'yyyyMMdd HH') = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd HH')
group by
s1.`uwConclueDate`
, s1.`LEVEL1COMCODE`
, s1.`LEVEL2COMCODE`
, s1.`LEVEL3COMCODE`
, s1.`LEVEL4COMCODE`
, s1.`startTime`
, s1.`risk`
)a1
left join ZB_DM.ZB_DM_MYSQL.TEAM_RISK for system_time as of s1.proctime as t1 left join ZB_DM.ZB_DM_MYSQL.TEAM_RISK for system_time as of s1.proctime as t1
on s1.`uwConclueDate` = t1.`uwConclueDate` on s1.`uwConclueDate` = t1.`uwConclueDate`
and s1.`LEVEL1COMCODE` = t1.`LEVEL1COMCODE` and s1.`LEVEL1COMCODE` = t1.`LEVEL1COMCODE`
...@@ -21,19 +45,8 @@ left join ZB_DM.ZB_DM_MYSQL.TEAM_RISK for system_time as of s1.proctime as t1 ...@@ -21,19 +45,8 @@ left join ZB_DM.ZB_DM_MYSQL.TEAM_RISK for system_time as of s1.proctime as t1
and s1.`LEVEL4COMCODE` = t1.`LEVEL4COMCODE` and s1.`LEVEL4COMCODE` = t1.`LEVEL4COMCODE`
and s1.`startTime` = t1.`startTime` and s1.`startTime` = t1.`startTime`
and s1.`risk` = t1.`risk` and s1.`risk` = t1.`risk`
and LongTimeToStringUDF(t1.log_time,'yyyyMMdd HH') = DATE_FORMAT(timestampadd(HOUR,-1,LOCALTIMESTAMP),'yyyyMMdd HH') and LongTimeToStringUDF(t1.log_time,'yyyyMMdd HH') = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd HH')
where
s1.`COMNAME` is not null
and s1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
and LongTimeToStringUDF(s1.log_time,'yyyyMMdd HH') = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd HH')
group by
s1.`uwConclueDate`
, s1.`LEVEL1COMCODE`
, s1.`LEVEL2COMCODE`
, s1.`LEVEL3COMCODE`
, s1.`LEVEL4COMCODE`
, s1.`startTime`
, s1.`risk`
; ;
-- ZB_DM_JRQDBF ZB_DM_今日签单保费 -- ZB_DM_JRQDBF ZB_DM_今日签单保费
......
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