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

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

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

select * from
    (select author,
    date_format(start_time,'%Y-%m') month, 
    round((sum(if(if_follow=1,1,0))-sum(if(if_follow=2,1,0)))/count(1),3) fans_growth_rate, 
    sum(sum(case if_follow when 1 then 1 when 2 then -1 end)) over(partition by author order by date_format(start_time,'%Y-%m')) total_fans
    from tb_user_video_log u 
    inner join tb_video_info v 
    on u.video_id=v.video_id 
    group by author,date_format(start_time,'%Y-%m')
    order by author,total_fans)t
where month between '2021-01' and '2021-12'

全部评论

相关推荐

11-19 18:44
已编辑
成都理工大学 Java
程序员花海:我面试过100+校招生,大厂后端面试不看ACM,竞赛经历含金量低于你有几份大厂实习 这个简历整体来看不错 可以海投
如何写一份好简历
点赞 评论 收藏
分享
11-27 16:41
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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