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

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

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

with s1 as(select author,left(start_time,7) month
,round(sum(case when if_follow = 2 then -1 when if_follow = 1 then 1 else 0 end)/count(*),3) fans_growth_rate
,sum(case when if_follow = 2 then -1 when if_follow = 1 then 1 else 0 end) sum_fans
from tb_user_video_log t1
left join tb_video_info t2
on t1.video_id = t2.video_id
where year(start_time) = '2021'
group by author,left(start_time,7))
select author,month,fans_growth_rate
,sum(sum_fans)over(partition by author order by month) total_fans
from s1
order by author,total_fans;

全部评论

相关推荐

吴offer选手:我卡在笔试才是最好笑的,甚至没给我发过笔试链接
投递哔哩哔哩等公司6个岗位
点赞 评论 收藏
分享
04-13 18:10
门头沟学院 Java
想熬夜的小飞象在秋招:被腾讯挂了后爸妈以为我失联了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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