select author, month,fans_growth_rate,
sum(follow)over(partition by author order by month) as total_fans
from
(select author, left(start_time,7) as month,
round(sum(if(if_follow=2,-1,if_follow))/count(video_id),3) as fans_growth_rate,
sum(if(if_follow=2,-1,if_follow)) as follow
from tb_user_video_log
join tb_video_info using (video_id)
where year(start_time)=2021
group by month,author
) a
order by author,total_fans