题解 | #每类视频近一个月的转发量/率#
https://www.nowcoder.com/practice/a78cf92c11e0421abf93762d25c3bfad
大佬解法1 SELECT b.tag, SUM(if_retweet) retweet_cnt, ROUND(SUM(if_retweet)/COUNT(*), 3) retweet_rate FROM tb_user_video_log a LEFT JOIN tb_video_info b ON a.video_id = b.video_id WHERE DATEDIFF(DATE((select max(start_time) FROM tb_user_video_log)), DATE(a.start_time)) <= 29 题目要求包含当天的前30天,用datediff(date1,date2)<=29就可以了 GROUP BY b.tag ORDER BY retweet_rate desc