|
@@ -14,7 +14,7 @@ ck = CkUtils()
|
|
|
def dw_channel():
|
|
|
sql="""
|
|
|
select
|
|
|
- dt,channel,pitcher,stage,platform,book,if(stage ='趣程15期' or stage ='趣程26期' or stage ='趣程30期','GDT','MP') type,
|
|
|
+ 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,
|
|
|
order_count,order_user,order_amount,
|
|
|
first_order_count,first_order_user,first_order_amount,
|
|
|
view_count,click_count,follow_user,
|
|
@@ -31,13 +31,13 @@ from
|
|
|
require_roi,require_mult from dw_daily_channel_cost) a
|
|
|
|
|
|
|
|
|
-full join
|
|
|
+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
|
|
|
|
|
|
-left join (
|
|
|
+left outer join (
|
|
|
select sum(if(user_order_count>=2,1,0)) reg_order_user_again,channel channel6,toDate(reg_date) dt6, ---复冲人数
|
|
|
sum(if(user_order_count>=3,1,0)) reg_order_user_again3,
|
|
|
sum(if(user_order_count>=4,1,0)) reg_order_user_again4,
|
|
@@ -47,7 +47,7 @@ left join (
|
|
|
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
|
|
|
|
|
|
-left join
|
|
|
+left outer join
|
|
|
(
|
|
|
select toDate(formatDateTime(reg_time,'%Y-%m-%d')) as dt2, ---新用户累计充值数据
|
|
|
channel as channel2,
|
|
@@ -56,13 +56,13 @@ left join
|
|
|
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
|
|
|
-left join
|
|
|
+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
|
|
|
|
|
|
- having order_amount+cost+reg_order_amount>0 '"""
|
|
|
+ having order_amount+cost+reg_order_amount>0"""
|
|
|
|
|
|
data=ck.execute(sql)
|
|
|
isql="insert into dw_channel values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
|