漏斗分析之SQL示例

分析需求条件如下
注册 -> 新手引导 -> 充值 -> 退出
register->guidance->recharge->logout
时间跨度2021-03-30~2021-03-31 窗口期1天
SQL示例如下
with t1 as (select _accountid,cast(_time as timestamp) as _time,date from register where date>='2021-03-30' and date <= '2021-03-31' 
),
t2 as (select _accountid,cast(_time as timestamp) as  _time,date from guidance where date>='2021-03-30' and date <= '2021-03-31'  
),
t3 as (select _accountid,cast(_time as timestamp) as  _time,date from recharge where date>='2021-03-30' and date <= '2021-03-31'  
),
t4 as (select _accountid,cast(_time as timestamp) as  _time,date from logout where date>='2021-03-30' and date <= '2021-03-31' 
)
select t1.date,
count(distinct t1._accountid) step1,
count(distinct t2._accountid) step2,
count(distinct t3._accountid) step3,
count(distinct t4._accountid) step4
from t1 
left join t2 on t1._accountid=t2._accountid and t1._time<t2._time and date_diff('second',t1._time,t2._time)<86400
left join t3 on t2._accountid=t3._accountid and t2._time<t3._time and date_diff('second',t1._time,t3._time)<86400
left join t4 on t3._accountid=t4._accountid and t3._time<t4._time and date_diff('second',t1._time,t4._time)<86400
GROUP BY t1.date
结果如下

在这里插入图片描述


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部