#不用窗口函数的解法
select t1.author,t1.month,t1.fans_growth_rate,sum(fans_cnt) as total_fans from (select author,date_format(start_time,'%Y-%m') as month ,round((count(if(if_follow=1,1,null))-count(if(if_follow=2,1,null)))/count(start_time),3) as fans_growth_rate from tb_user_video_log as a right join tb_video_info as b using(video_id) where year(start_time) = 2021 group by author,month) as t1
left join
(select author ,date_format(start_time,'%Y-%m') as month ,round((count(if(if_follow= 1,1,null))-count(if(if_follow= 2,1,null)))/count(start_time),3) as fans_growth_rate ,count(if(if_follow =1,1,null))-count(if(if_follow=2,1,null)) as fans_cnt from tb_user_video_log as a right join tb_video_info as b using(video_id) where year(start_time)= 2021 group by author,month) as t2
on t1.author= t2.author and t1.month>=t2.month group by t1.author,t1.month order by author,total_fans