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

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

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

select author,
month,
round((addfans)/cnt,3) as fans_growth_rate,
sum(addfans) over(partition by author order by author,month) as total_fans
from(
    select
    date_format(start_time,'%Y%-%m') as month,
    sum(if(if_follow=2,-1,if_follow)) as addfans,author,
    count(*) as cnt
    from tb_user_video_log
    join tb_video_info using(video_id)
    group by author,month
)a
where month >='2020-12'
order by author,total_fans

从0开始的SQL之旅 文章被收录于专栏

从0开始的SQL之旅

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务