select b.tag , sum(if_retweet) AS retweet_cnt, round(sum(if_retweet)/count(*),3) as retweet_rate
FROM tb_user_video_log a 
LEFT JOIN tb_video_info b using(video_id)
where DATEDIFF(DATE((select max(start_time) from tb_user_video_log)),DATE(a.start_time)) <= 29
group by b.tag
order by retweet_rate desc

最近30天的,找时间的最大值,用其他的时间值和他比较,天数之差小于等于29