|
@@ -14,7 +14,7 @@ ck = CkUtils()
|
|
|
def dw_channel():
|
|
|
sql="""
|
|
|
select
|
|
|
- if(dt4='1970-01-01',dt,dt4) dt,if(channel4='',channel,channel4) channel,pitcher,stage,platform,book,if(stage ='趣程15期' or stage ='趣程26期' or stage ='趣程30期','GDT','MP') type,
|
|
|
+ dt1,channel1,pitcher,stage,platform,book,if(stage ='趣程15期' or stage ='趣程26期' or stage ='趣程30期','GDT','MP') type,
|
|
|
order_count,order_user,order_amount,
|
|
|
first_order_count,first_order_user,first_order_amount,
|
|
|
view_count,click_count,follow_user,
|
|
@@ -25,17 +25,19 @@ select
|
|
|
reg_order_user_again4,
|
|
|
reg_order_user_again5,
|
|
|
reg_order_user_again6
|
|
|
-from
|
|
|
-(select dt,channel, pitcher,stage,platform,book,cost,view_count,click_count, ---基础属性和消耗数据
|
|
|
+from (
|
|
|
+ select
|
|
|
+ if(dt4='1970-01-01',dt,dt4) dt1,if(channel4='',channel,channel4) channel1,
|
|
|
+ pitcher,stage,platform,book,cost,view_count,click_count, ---基础属性和消耗数据
|
|
|
follow_user,web_view_count,platform_view_count,web_order_count,type,
|
|
|
- require_roi,require_mult from dw_daily_channel_cost) a
|
|
|
+ require_roi,require_mult,order_count,order_user,order_amount from
|
|
|
|
|
|
-
|
|
|
-full outer join
|
|
|
+ (select * from dw_daily_channel_cost) aa
|
|
|
+ full outer join
|
|
|
(select date as dt4,channel as channel4,count(1) as order_count, ---账面充值
|
|
|
count(distinct user_id) as order_user,sum(amount) as order_amount
|
|
|
- from order where status=2 group by date,channel) d
|
|
|
- on dt=dt4 and channel=channel4
|
|
|
+ from order where status=2 group by date,channel) dd
|
|
|
+ on dt=dt4 and channel=channel4) a
|
|
|
|
|
|
left outer join (
|
|
|
select sum(if(user_order_count>=2,1,0)) reg_order_user_again,channel channel6,toDate(reg_date) dt6, ---复冲人数
|
|
@@ -45,7 +47,7 @@ left outer join (
|
|
|
sum(if(user_order_count>=6,1,0)) reg_order_user_again6
|
|
|
from (select formatDateTime(reg_time,'%Y-%m-%d') reg_date,channel,count(1) user_order_count
|
|
|
from order where status=2 group by formatDateTime(reg_time,'%Y-%m-%d') ,user_id,channel) x group by reg_date,channel
|
|
|
- ) f on dt=dt6 and channel=channel6
|
|
|
+ ) f on dt1=dt6 and channel1=channel6
|
|
|
|
|
|
left outer join
|
|
|
(
|
|
@@ -55,12 +57,12 @@ left outer join
|
|
|
count(distinct user_id) as reg_order_user,
|
|
|
count(1) as reg_order_count
|
|
|
from order where status=2 and reg_time>'2019-03-18 00:00:00' group by toDate(formatDateTime(reg_time,'%Y-%m-%d')),channel) b
|
|
|
- on dt=dt2 and channel=channel2
|
|
|
+ on dt1=dt2 and channel1=channel2
|
|
|
left outer join
|
|
|
(select date as dt3,channel as channel3,count(1) as first_order_count, ---新用户首日充值
|
|
|
count(distinct user_id) as first_order_user,sum(amount) as first_order_amount
|
|
|
from order where status=2 and toDate(reg_time)=date group by date,channel) c
|
|
|
- on dt=dt3 and channel=channel3
|
|
|
+ on dt1=dt3 and channel1=channel3
|
|
|
|
|
|
having order_amount+cost+reg_order_amount>0"""
|
|
|
|