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

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

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

select 
    author,
    month,
    fans_growth_rate,
    sum(month_fans) over (partition by author order by month) as total_fans
from(
    select 
        author,
        date_format(start_time,'%Y-%m') as month,
        round((sum(if(if_follow=1,1,0))-sum(if(if_follow=2,1,0)))/count(*),3) as fans_growth_rate,
        sum(if(if_follow=1,1,0))-sum(if(if_follow=2,1,0)) as month_fans
    from
        tb_user_video_log as a
    left join tb_video_info as b
    on a.video_id = b.video_id
    where year(start_time) = 2021
    group by author,date_format(start_time,'%Y-%m')) as c
order by author,total_fans

全部评论

相关推荐

04-25 18:13
五邑大学 Java
无面如何呢:用心包装一下自己的实习
点赞 评论 收藏
分享
刘湘_passion:出国旅游?那就小心你的腰子咯
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务