Commit a24ee3f8 by mengdongxing

Update tkdm_data_retention_detial_day.sql

parent 3b69f2fc
insert overwrite table tkdm.tkdm_data_retention_detial_day partition(ds='2017-02-28') insert overwrite table tkdm.tkdm_data_retention_detial_day partition(ds='2017-02-28')
select /*+ mapjoin(b) */ a.appid, select /*+ mapjoin(b) */ a.appid,
a.cid,
date_sub('2017-02-28',1) as ds_user, date_sub('2017-02-28',1) as ds_user,
a.num_user, a.num_user,
a.d1_user, a.d1_user,
...@@ -10,6 +11,7 @@ select /*+ mapjoin(b) */ a.appid, ...@@ -10,6 +11,7 @@ select /*+ mapjoin(b) */ a.appid,
b.isgame b.isgame
from from
(select appid, (select appid,
cid,
sum(num_install) as num_user, sum(num_install) as num_user,
sum(num_newuser_reten_d1) as d1_user, sum(num_newuser_reten_d1) as d1_user,
round(sum(num_newuser_reten_d1)/sum(num_install),4) as d1_rate round(sum(num_newuser_reten_d1)/sum(num_install),4) as d1_rate
...@@ -18,7 +20,7 @@ from ...@@ -18,7 +20,7 @@ from
dt=date_sub('2017-02-28',1) and dt=date_sub('2017-02-28',1) and
campaignid !='_default_' and campaignid !='_default_' and
cid!=-2 cid!=-2
group by appid group by appid,cid
having sum(num_install)>0 having sum(num_install)>0
) as a ) as a
...@@ -37,6 +39,7 @@ join ...@@ -37,6 +39,7 @@ join
create EXTERNAL table tkdm_data_retention_detial_day( create EXTERNAL table tkdm_data_retention_detial_day(
appid string, appid string,
cid int,
ds_user string, ds_user string,
num_user int, num_user int,
d1_user int, d1_user int,
...@@ -49,4 +52,4 @@ PARTITIONED BY (ds string) ...@@ -49,4 +52,4 @@ PARTITIONED BY (ds string)
ROW FORMAT DELIMITED ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t' FIELDS TERMINATED BY '\t'
location 's3://reyuntkio/warehouse/tkio/tkdm.db/tkdm_data_retention_detial_day' location 's3://reyuntkio/warehouse/tkio/tkdm.db/tkdm_data_retention_detial_day'
; ;
\ No newline at end of file
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