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

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

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

with conv_temp as (
select t.campaign_id, t.campaign_name, t.conv_2023_02, t.conv_2024_02, t.conv_2024_01,
t.conv_2024_02 - t.conv_2023_02 as yoy_delta,
t.conv_2024_02 - t.conv_2024_01 as mom_delta,
t.north_pct_2023, t.south_pct_2023, t.east_pct_2023
from (select c.campaign_id ,c.campaign_name ,
sum(case when YEAR(event_time)=2023 and month(event_time)=2 then 1 else  0 end) as conv_2023_02,
sum(case when YEAR(event_time)=2024 and month(event_time)=2 then 1 else  0 end) as conv_2024_02,
sum(case when YEAR(event_time)=2024 and month(event_time)=1 then 1 else  0 end) as conv_2024_01,
COALESCE(round(sum(case when  region='华北' and YEAR(event_time)=2023 then 1 else 0 end)/
NULLIF(sum(case when  YEAR(event_time)=2023 then 1 else 0 end), 0)*100,2), 0.00) as north_pct_2023,
COALESCE(round(sum(case when  region='华南' and YEAR(event_time)=2023 then 1 else 0 end)/
NULLIF(sum(case when  YEAR(event_time)=2023 then 1 else 0 end), 0)*100,2), 0.00) as south_pct_2023,
COALESCE(round(sum(case when  region='华东' and YEAR(event_time)=2023 then 1 else 0 end)/
NULLIF(sum(case when  YEAR(event_time)=2023 then 1 else 0 end), 0)*100,2), 0.00) as east_pct_2023
from  Campaigns c
left join  Events e on e.campaign_id=c.campaign_id
and e.event_type='signup'
left join  Users u on u.user_id=e.user_id
group by c.campaign_id,c.campaign_name
) t 
),
avg_click_temp as (
select t.campaign_id, t.user_id, max(e.event_time) as min_click, t.sign_time
from ( select  campaign_id,user_id,event_time as sign_time
from Events
where event_type='signup'
and YEAR(event_time)=2024 and month(event_time)=2
group by campaign_id,user_id,event_time
)  t
join Events e on t.campaign_id=e.campaign_id
and t.user_id=e.user_id
where e.event_time<t.sign_time
and e.event_type='click'
and YEAR(e.event_time)=2024 and month(e.event_time)=2
group by t.campaign_id, t.user_id, t.sign_time
),
top_channel_temp as (
select campaign_id,channel ,rank() over(partition by campaign_id order by channel_count desc, CONCAT(channel)) as rn
from (select campaign_id,channel,count(*) as channel_count 
from Events 
where YEAR(event_time)=2024 and month(event_time)=2
and event_type='signup'
group by campaign_id,channel) t
)
select ct.campaign_id, ct.campaign_name, ct.conv_2023_02, ct.conv_2024_02, ct.conv_2024_01,
ct.yoy_delta, ct.mom_delta, ct.north_pct_2023, ct.south_pct_2023, ct.east_pct_2023,
COALESCE(round(avg(timestampdiff(SECOND, act.min_click, act.sign_time))/60,2), 0.00) as avg_click_to_signup_min_2024_02,
tct.channel as top_channel_2024_02
from conv_temp ct
left join avg_click_temp act on act.campaign_id=ct.campaign_id
left join top_channel_temp tct on tct.campaign_id=ct.campaign_id
where tct.rn=1
group by ct.campaign_id, ct.campaign_name, ct.conv_2023_02, ct.conv_2024_02, ct.conv_2024_01,
ct.yoy_delta, ct.mom_delta, ct.north_pct_2023, ct.south_pct_2023, ct.east_pct_2023, tct.channel
order by ct.campaign_id, ct.campaign_name;

全部评论

相关推荐

点赞 评论 收藏
分享
昨天 00:04
已编辑
门头沟学院 Java
约面的挺突然。。狠下心接了1.自我介绍2.讲讲JAVA的反射3.可以继续讲讲AOP,动态代理[&nbsp;因为讲反射不小心吟唱到了例如AOP的动态代理,但是这块记忆的非常不熟,结果磕磕绊绊&nbsp;]4.项目我看你写了AOP和注解,具体怎么实现滑动窗口限流的[&nbsp;梦到什么说什么,吟唱八股发散千万不要散到自己不熟悉的区域&nbsp;]5.也讲讲为什么另一个项目选择令牌桶,具体流程6.&nbsp;OK,讲讲&nbsp;Redis&nbsp;的数据类型?还有吗?就了解这五种嘛[&nbsp;把5个的基础类型从应用对比到历届底层全都吟唱了一遍。一句还有吗直接没力气了,简历就写了理解5种,别的我是真一点没看TT&nbsp;]7.讲讲Redission分布式锁实现8.这个指数退避怎么实现的9.在这里有考虑去保障幂等性嘛10.这里为什么使用指数退避呢?&nbsp;什么时候用均匀重传[已经晕过去了说不了解,刚说了后就意识到,估计应该说指数退避能缓解压力防止下游服务器雪崩之类的]11.ok,那讲讲JMM12.讲讲RocketMQ如何保证的不丢消息13.讲讲RocketMQ延迟消息原理14.讲讲项目Redis实现会话记忆这一块15.如果ai调用function&nbsp;calling出现幻觉,有考虑怎么解决吗?[&nbsp;不了解,面试官说什么接口幂等化,高危操作人工防护,没在听,感觉人已经飞升了TT&nbsp;]16.mcp了解嘛?和function&nbsp;calling有什么区别[&nbsp;依旧不了解,只能说了个前者规范架构抽象解耦,后者耦合高只能算个工具调用]17.AI生成代码的代码质量怎么保障,那平时如何review的呢18.算法。lc215&nbsp;&nbsp;数组中最大第k个元素19.打算考研还是本科就业20.反问1️⃣有哪里不足,有哪些需要提高的部分。[主要说知识广度不够,多刷算法,让我别太紧张]2️⃣部门业务会做什么人生第二次面试。感觉大厂面试官的气场压力很大应该凉了不过这次面试非常锻炼心态,多面试,多面试。
Luxlord:面经太硬核了
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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