题解 | SaaS产品高价值用户活跃度分析

SaaS产品高价值用户活跃度分析

https://www.nowcoder.com/practice/439f6de3254143e7b3673ed0259d98b0

with t1 as (
    select distinct u.user_id,user_name,registration_date,plan_type,event_id,event_type,event_timestamp
    from users u join user_events ue on u.user_id = ue.user_id
    where registration_date between '2025-01-01 00:00:00' and '2025-06-30 23:59:59' and plan_type = 'Pro'
    and event_timestamp between '2025-01-01 00:00:00' and '2025-03-31 23:59:59' and event_type = 'login'
),
t2 as (
    select u.user_id,
    sum(if(event_type='create_task',5,if(event_type='export_report',10,if(event_type='invite_member',8,1)))) total_activity_score
    from users u left join user_events ue on u.user_id = ue.user_id
    group by u.user_id
),
t3 as (
    select u.user_id,round(count(event_type)/3,2) avg_monthly_events
    from users u left join user_events ue on u.user_id = ue.user_id
    where event_timestamp between '2025-01-01 00:00:00' and '2025-03-31 23:59:59'
    group by u.user_id 
)
select concat(user_name,'(',t1.user_id,')') user_profile,total_activity_score,avg_monthly_events
from t1 join t2 on t1.user_id = t2.user_id join t3 on t1.user_id = t3.user_id
order by total_activity_score desc,avg_monthly_events desc,t1.user_id

全部评论

相关推荐

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

创作者周榜

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