
背景:产品作了一个周期7天活动,用户能够每一天解锁一个任务,完成后发放奖励;微信
须要统计截止到每一天,用户完成任务天数;flex
目的:用户参与活动的兴趣度;ui
活动海报图:
spa
分析思路:.net
这就是一个累计求和,截止到莫一天的累计数值有多少;3d
具体过程:blog
这里抽取两个用户case的,以分析其过程,这里已经提早筛选完成任务的用户;ci
抽取用户明细以下:get
统计截止到一天,用户累计完成活动天数数据分析
附上代码:
with , tmp_da_user as (
select
ds
,uid
,count(distinct ds) as 完整天数
from tmp_t_user_takse_detail
where status_name = '完成'
and uid in ('203111313364823804','1833903495100023')
group by
ds
,uid
)
,tmp_da_user_tack_acc as (
select *
,sum(完整天数) over(partition by uid order by ds ) as total_cnt
from tmp_da_user
)
select
ds
,concat(total_cnt,'天') as 累计完成任务量_完成N天任务
,count(distinct uid) as 完成任务人数
from tmp_da_user_tack_acc
group by
ds
,total_cnt
本文分享自微信公众号 - SQL数据分析(dianwu_dw)。
若有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一块儿分享。