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

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

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

select a.author,a.month,a.ra,
       sum(fans) over(partition by a.author order by a.month) mf
from 
    (select author,date_format(end_time,'%Y-%m') month,
           round(sum(case when if_follow=2 then -1
                else if_follow end)/count(start_time),3) as ra
           ,sum(case when if_follow=2 then -1
                else if_follow end) fans
    from tb_user_video_log t1
    join tb_video_info t2
    on t1.video_id=t2.video_id
    where year(end_time)='2021'
    group by author,month
    ) a
order by a.author,mf;

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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