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

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

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

select 
b.author,
date_format(a.start_time,'%Y-%m') as month,
round(sum(case when if_follow = 2 then -1 else if_follow end)/count(uid),3) as fans_growth_rate,
sum(sum(case when if_follow = 2 then -1 else if_follow end)) over(partition by b.author order by date_format(a.start_time,'%Y-%m')) as total_fans
from
tb_user_video_log a
left join
tb_video_info b
on a.video_id = b.video_id
where date_format(a.start_time,'%Y') = '2021'
group by b.author,date_format(a.start_time,'%Y-%m')
order by 1,4

感觉自己太菜了,连窗口函数都不知道,但练习了有所提高

全部评论

相关推荐

06-19 19:06
门头沟学院 Java
码农索隆:别去东软,真学不到东西,真事
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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