题解 | 内容社区用户活跃度、转化与广告归因分析

内容社区用户活跃度、转化与广告归因分析

https://www.nowcoder.com/practice/e491704f99ed4affb1d42127bf16a4a9

select a.campaign_id campaign_id,campaign_name,conv_2023_02,conv_2024_02,conv_2024_01,yoy_delta,mom_delta,north_pct_2023,south_pct_2023,east_pct_2023,avg_click_to_signup_min_2024_02,channel top_channel_2024_02 
from (
select Campaigns.campaign_id campaign_id,campaign_name
,count(case when date_format(event_time,'%Y-%m')='2023-02' and event_type ='signup' then 1 else null end) conv_2023_02
,count(case when date_format(event_time,'%Y-%m')='2024-02' and event_type ='signup' then 1 else null end) conv_2024_02
,count(case when date_format(event_time,'%Y-%m')='2024-01' and event_type ='signup' then 1 else null end) conv_2024_01
,count(case when date_format(event_time,'%Y-%m')='2024-02' and event_type ='signup' then 1 else null end)-count(case when date_format(event_time,'%Y-%m')='2023-02' and event_type ='signup' then 1 else null end) yoy_delta
,count(case when date_format(event_time,'%Y-%m')='2024-02' and event_type ='signup' then 1 else null end)-count(case when date_format(event_time,'%Y-%m')='2024-01' and event_type ='signup' then 1 else null end) mom_delta
,coalesce(round(count(case when date_format(event_time,'%Y')='2023' and event_type ='signup'  and region='华北' then 1 else null end)/count(case when date_format(event_time,'%Y')='2023' and event_type ='signup' then 1 else null end)*100,2),0.00) north_pct_2023 
,coalesce(round(count(case when date_format(event_time,'%Y')='2023' and event_type ='signup'  and region='华南' then 1 else null end)/count(case when date_format(event_time,'%Y')='2023' and event_type ='signup' then 1 else null end)*100,2),0.00) south_pct_2023  
,coalesce(round(count(case when date_format(event_time,'%Y')='2023' and event_type ='signup'  and region='华东' then 1 else null end)/count(case when date_format(event_time,'%Y')='2023' and event_type ='signup' then 1 else null end)*100,2),0.00) east_pct_2023 
from Campaigns
left join Events
on Campaigns.campaign_id=Events.campaign_id
left join Users
on Events.user_id=Users.user_id
group by Campaigns.campaign_id,campaign_name)a 
left join (
    select campaign_id
    ,coalesce(round(avg(min_2024_02),2),0.00) avg_click_to_signup_min_2024_02
    from(
    select campaign_id ,min_2024_02
    from(
    select campaign_id ,user_id,event_time ,event_type
    ,timestampdiff(minute,lag(event_time)over(partition by campaign_id,user_id order by event_time),event_time) min_2024_02
    from Events
    where date_format(event_time,'%Y-%m')='2024-02'
    )b 
    where event_type='signup'
    and min_2024_02!=event_type)c 
    group by campaign_id
)d 
on a.campaign_id=d.campaign_id
left join (
    select campaign_id,channel
    from(
    select campaign_id,channel 
    ,count(case when event_type ='signup' then 1 else null end) cnt
    ,row_number()over(partition by campaign_id order by count(case when event_type ='signup' then 1 else null end) desc,FIELD(channel, 'app', 'mini', 'web')) rn 
    from Events
    where date_format(event_time,'%Y-%m')='2024-02'
    group by campaign_id,channel )e 
    where rn=1
)f 
on a.campaign_id=f.campaign_id


全部评论

相关推荐

owwhy:难,技术栈在嵌入式这块显得非常浅,并且简历有大问题。教育经历浓缩成两行就行了,写什么主修课程,说的不好听这块没人在意,自我评价删了,项目写详细点,最终简历缩成一页。相关技能怎么说呢,有点差了,还写成这么多行
投了多少份简历才上岸
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务