WITH tongji AS ( SELECT a.uid, b.tag, a.start_time, a.end_time, a.if_retweet, (SELECT MAX(end_time) FROM tb_user_video_log) AS last_time FROM tb_user_video_log AS a LEFT JOIN tb_video_info AS b ON a.video_id = b.video_id ) SELECT tag, COUNT(CASE WHEN if_retweet = 1 THEN 1 END) AS retweet_cnt, ROUND(...