:)题外话
好久没写随笔了 最近总是为别的事烦心 揽私活啦 感情问题啦 情绪低落什么的 果然心情不好容易生病 昨天烧了一整天 还好都过去啦 家人是我的全部 想来他们是支撑我又带给我压力的很大一部分因素 注孤生的程序猿宝宝还是多多提升自己吧(づ??????)づ
select t1.*,
case when coalesce(t2.SCORE,0) = 0 then 0 else
round((t1.SCORE-t2.SCORE)/t2.SCORE*100,2) end SCORE_HB, //条件:当前字段不为空且不为0时,可进行环比运算
case when coalesce(t2.ANALYZE_DELAY,0) = 0 then 0 else
round((t1.ANALYZE_DELAY-t2.ANALYZE_DELAY)/t2.ANALYZE_DELAY*100,2) end ANALYZE_DELAY_HB,
case when coalesce(t2.LINK_DELAY,0) = 0 then 0 else
round((t1.LINK_DELAY-t2.LINK_DELAY)/t2.LINK_DELAY*100,2) end LINK_DELAY_HB,
case when coalesce(t2.FIRST_GET_DELAY,0) = 0 then 0 else
round((t1.FIRST_GET_DELAY-t2.FIRST_GET_DELAY)/t2.FIRST_GET_DELAY*100,2) end FIRST_GET_DELAY_HB,
case when coalesce(t2.FIRST_PAGE_DELAY,0) = 0 then 0 else
round((t1.FIRST_PAGE_DELAY-t2.FIRST_PAGE_DELAY)/t2.FIRST_PAGE_DELAY*100,2) end FIRST_PAGE_DELAY_HB,
case when coalesce(t2.DOWNLOAD_RATE,0) = 0 then 0 else
round((t1.DOWNLOAD_RATE-t2.DOWNLOAD_RATE)/t2.DOWNLOAD_RATE*100,2) end DOWNLOAD_RATE_HB,
case when coalesce(t2.WEBLOAD_DELAY,0) = 0 then 0 else
round((t1.WEBLOAD_DELAY-t2.WEBLOAD_DELAY)/t2.WEBLOAD_DELAY*100,2) end WEBLOAD_DELAY_HB,
case when coalesce(t2.TOTAL_DELAY,0) = 0 then 0 else
round((t1.TOTAL_DELAY-t2.TOTAL_DELAY)/t2.TOTAL_DELAY*100,2) end TOTAL_DELAY_HB,
case when coalesce(t2.DOWNLOAD_DELAY,0) = 0 then 0 else
round((t1.DOWNLOAD_DELAY-t2.DOWNLOAD_DELAY)/t2.DOWNLOAD_DELAY*100,2) end DOWNLOAD_DELAY_HB,
case when coalesce(t2.ANALYZE_SUC_RATE,0) = 0 then 0 else
round((t1.ANALYZE_SUC_RATE-t2.ANALYZE_SUC_RATE)/t2.ANALYZE_SUC_RATE*100,2) end ANALYZE_SUC_RATE_HB,
case when coalesce(t2.LINK_SUC_DELAY,0) = 0 then 0 else
round((t1.LINK_SUC_DELAY-t2.LINK_SUC_DELAY)/t2.LINK_SUC_DELAY*100,2) end LINK_SUC_DELAY_HB,
case when coalesce(t2.DOWNLOAD_SIZE,0) = 0 then 0 else
round((t1.DOWNLOAD_SIZE-t2.DOWNLOAD_SIZE)/t2.DOWNLOAD_SIZE*100,2) end DOWNLOAD_SIZE_HB,
case when coalesce(t2.USEABLE_RATE,0) = 0 then 0 else
round((t1.USEABLE_RATE-t2.USEABLE_RATE)/t2.USEABLE_RATE*100,2) end USEABLE_RATE_HB
from
(select
DAY_KEY,
CITY_KEY,
OPER_KEY,
APP_TYPE_KEY,
APP_SUBTYPE_KEY,
HOST_KEY,
round(SCORE,2)as SCORE,//进行任何数据处理后都要给数据列定义别名
ANALYZE_DELAY,
LINK_DELAY,
FIRST_GET_DELAY,
FIRST_PAGE_DELAY,
DOWNLOAD_RATE,
WEBLOAD_DELAY,
TOTAL_DELAY,
DOWNLOAD_DELAY,
round(ANALYZE_SUC_RATE,2)as ANALYZE_SUC_RATE,
LINK_SUC_DELAY,
DOWNLOAD_SIZE,
round(USEABLE_RATE,2)as USEABLE_RATE,
NUM
from DW_FT_WEB_CITY_L2_DY
where 1=1
$[and city_key = (:{city})]
$[and day_key = (:{time})]) t1
left join //关联查询
(
select
DAY_KEY,
CITY_KEY,
OPER_KEY,
APP_TYPE_KEY,
APP_SUBTYPE_KEY,
HOST_KEY,
round(SCORE,2)as SCORE,
ANALYZE_DELAY,
LINK_DELAY,
FIRST_GET_DELAY,
FIRST_PAGE_DELAY,
DOWNLOAD_RATE,
WEBLOAD_DELAY,
TOTAL_DELAY,
DOWNLOAD_DELAY,
round(ANALYZE_SUC_RATE,2)as ANALYZE_SUC_RATE,
LINK_SUC_DELAY,
DOWNLOAD_SIZE,
round(USEABLE_RATE,2)as USEABLE_RATE,
NUM
from DW_FT_WEB_CITY_L2_DY
where 1=1
$[and city_key = (:{city})]
$[and day_key = to_number(to_char(to_date(‘:{time}‘,‘yyyyMMdd‘)-1,‘yyyyMMdd‘))]) t2
on t1.CITY_KEY=t2.CITY_KEY and t1.OPER_KEY=t2.OPER_KEY