题解 | #每个创作者每月的涨粉率及截止当前的总粉丝量#

每个创作者每月的涨粉率及截止当前的总粉丝量

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

select
    author,
    `month`,
    round((count(if(if_follow=1,1,null))- count(if(if_follow=2,1,null))) / count(look_time),3) fans_growth_rate,
    sum(sum(case when if_follow=1 then 1
        when if_follow=2 then -1
        else 0 end)) over(partition by author order by month) total_fans
from 
(
    select
        t1.uid,
        t1.video_id,
        t1.if_follow,
        t2.author,
        timestampdiff(second,t1.start_time,t1.end_time) look_time,
        substring(t1.end_time,1,7) as month
    from tb_user_video_log t1
    join tb_video_info t2 on t1.video_id = t2.video_id
    where year(t1.end_time) = 2021
)t
group by author,month
order by author,total_fans

全部评论

相关推荐

2025-12-19 19:02
西安交通大学 Java
程序员牛肉:双九,而且还是西交这种比较好的985九没必要再投日常了。你投中小厂,人家会觉得你学历这么顶还面试肯定是海投的,过了你也不去。所以不约你了。 直接准备暑期实习就好,现在你可以面试。但是目的不再是去日常实习了,而是熟悉面试节奏。 后续把精力放到八股,算法和AI知识上。抽空把自己这两个项目换了,怎么选项目可以看看我主页写的文章。 你学历不错的,不要焦虑
那些拿到大厂offer的...
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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