题解 | #每类视频近一个月的转发量/率#
每类视频近一个月的转发量/率
https://www.nowcoder.com/practice/a78cf92c11e0421abf93762d25c3bfad
SELECT tag, SUM(IF(if_retweet=1, 1, 0)) AS retweet_cut, ROUND(AVG(IF(if_retweet=1, 1, 0)), 3) AS retweet_rate FROM tb_user_video_log t1 JOIN tb_video_info t2 USING(video_id) WHERE DATEDIFF((SELECT MAX(end_time) FROM tb_user_video_log), end_time) < 30 GROUP BY tag ORDER BY retweet_rate DESC
老是忘记不能直接在函数里直接写MAX(),要用一个子查询,麻了,,,