题解 | #每类视频近一个月的转发量/率#
每类视频近一个月的转发量/率
https://www.nowcoder.com/practice/a78cf92c11e0421abf93762d25c3bfad
这个题还是比较简单,给的条件比较清晰,就不过多说明。不像上一组题有些题描述不清晰,上一组题不知道是牛客自己出的还是kiang来的。
select d.tag, sum(a.if_retweet) as retweet_cut, format(sum(a.if_retweet)/count(1),3) as retweet_rate from tb_user_video_log a join (select max(b.start_time) as start_time from tb_user_video_log b) c on date_format(a.start_time,"%Y%m%d") >= date_format(date_sub(c.start_time,interval 29 day),'%Y%m%d') join tb_video_info d on a.video_id = d.video_id group by d.tag order by retweet_rate desc