题解 | #每类视频近一个月的转发量/率#
每类视频近一个月的转发量/率
https://www.nowcoder.com/practice/a78cf92c11e0421abf93762d25c3bfad
SELECT tag, SUM(if_retweet) AS retweet_cut, ROUND(SUM(if_retweet)/COUNT(*), 3) AS retweet_rate FROM tb_user_video_log AS u INNER JOIN tb_video_info AS v USING(video_id) WHERE end_time BETWEEN (SELECT DATE_SUB(MAX(end_time), INTERVAL 30 DAY) FROM tb_user_video_log) AND (SELECT MAX(end_time) FROM tb_user_video_log) GROUP BY tag ORDER BY retweet_rate DESC