Commit 796681e1 authored by 胡涛's avatar 胡涛

指标统计sql脚本

parent 2070fe9c
......@@ -11,7 +11,7 @@ SELECT
, s1.`LEVEL4COMCODE` as `LEVEL4COMCODE`
, s1.`startTime` as `startTime`
, s1.`risk` as `risk`
, sum(cast(s1.`cost` as DECIMAL(18, 2))) as `cost`
, sum(cast(s1.`cost` as DECIMAL(18, 2)) + if(t1.`cost` is null,0, cast(t1.`cost` as DECIMAL(18, 2)))) as `cost`
from ZB_ODS.ZB_ODS_KAFKA.CBDATA s1
left join ZB_DM.ZB_DM_MYSQL.TEAM_RISK for system_time as of s1.proctime as t1
on s1.`uwConclueDate` = t1.`uwConclueDate`
......@@ -21,7 +21,7 @@ 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.`startTime` = t1.`startTime`
and s1.`risk` = t1.`risk`
and left(t1.log_time,8) = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
and LongTimeToStringUDF(t1.log_time,'yyyyMMdd HH') = DATE_FORMAT(timestampadd(HOUR,-1,LOCALTIMESTAMP),'yyyyMMdd HH')
where
s1.`COMNAME` is not null
and s1.`uwConclueDate` = DATE_FORMAT(LOCALTIMESTAMP,'yyyyMMdd')
......
-- ZB_DM_TDHZJG_RISK ZB_DM_团队汇总结果_险种
-- ZB_DM_TEAM_RISK ZB_DM_团队汇总结果_险种
......@@ -13,10 +13,8 @@ SELECT
, s1.`LEVEL4COMCODE` as `LEVEL4COMCODE`
, s1.`startTime` as `startTime`
, s1.`risk` as `risk`
, s1.`chnl` as `chnl`
, s1.`businessNatureCode` as `businessNatureCode`
, cast (sum(cast(s1.`cost` as DECIMAL(18, 2))) as varchar ) as `cost`
, DATE_FORMAT(top_end(s1.row_time, interval '1' hour ) ,'yyyy-MM-dd HH:mm:ss') as `log_time`
, cast (DateTimeToLongUDF(hop_end(s1.row_time, interval '1' hour , interval '24' hour) ) as varchar ) as `log_time`
from (
select
*
......@@ -35,9 +33,7 @@ group by
, s1.`LEVEL4COMCODE`
, s1.`startTime`
, s1.`risk`
, s1.`chnl`
, s1.`businessNatureCode`
, top(s1.row_time, interval '1' hour)
, hop(s1.row_time, interval '1' hour, interval '24' hour)
;
......
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