SELECT tag, CONCAT (t1.avg_play_progress, "%") from ( select tag, round( avg( if ( timestampdiff (second, u.start_time, u.end_time) >= v.duration, 1, timestampdiff (SECOND, u.start_time, u.end_time) / v.duration ) ) * 100, 2 ) as avg_play_progress from tb_user_video_log u LEFT JOIN tb_video_info ...