select tag , sum((if(if_retweet='1',1,0))) retweet_cut , round(sum((if(if_retweet='1',1,0)))/count(start_time),3) retweet_rate from tb_user_video_log a left join tb_video_info b using (video_id) where timestampdiff(day,start_time,(SELECT MAX(start_time) FROM tb_user_video_log)) < 30 group by tag ...