题解 | #每类视频近一个月的转发量/率#
每类视频近一个月的转发量/率
https://www.nowcoder.com/practice/a78cf92c11e0421abf93762d25c3bfad
select tag, sum(if_retweet) as retweet_cut, round(sum(if_retweet)/count(tb1.video_id),3) as retweet_rate from tb_user_video_log tb1 join tb_video_info tb2 on tb1.video_id = tb2.video_id where datediff((select max(start_time) from tb_user_video_log),start_time)<30 group by tb2.tag order by retweet_rate desc
难懂就难懂在“什么叫做[最近]”,题目虽然解释了范围但是没有解释怎么定义“现在”,后来看了大佬的解析才发现“现在”就是最大的start_time。写的稍微复杂了些,毕竟我水平有限。