题解 | #每个创作者每月的涨粉率及截止当前的总粉丝量#
每个创作者每月的涨粉率及截止当前的总粉丝量
http://www.nowcoder.com/practice/d337c95650f640cca29c85201aecff84
笨蛋方法,要求什么就搞什么
select author,m,r fans_growth_rate,sum(s) over(partition by author order by m) total_fans
from(select author,m,sum(if_follow) s,round(sum(if_follow)/count(*),3) r
from(
select author,date_format(start_time,'%Y-%m') m,case when if_follow=2 then -1 else if_follow end if_follow
from tb_user_video_log l
join tb_video_info i on l.video_id=i.video_id
where year(start_time)=2021
) a
group by author,m
) b
order by author,total_fans


