题解 | #每类视频近一个月的转发量/率#
每类视频近一个月的转发量/率
http://www.nowcoder.com/practice/a78cf92c11e0421abf93762d25c3bfad
select tag,sum(if(if_retweet=1,1,0)) as retweet_cut, round(sum(if(if_retweet=1,1,0))/count(1),3) as retweet_rate from ( select tag,start_time,if_retweet, max(date_format(start_time,'%Y%m%d'))over(order by start_time desc) as max_time from tb_video_info t1 join tb_user_video_log t2 on t1.video_id = t2.video_id ) t where datediff(max_time,date_format(start_time,'%Y%m%d')) <= 29 group by tag order by retweet_rate desc