select info.video_id, round(sum(case when timestampdiff(second, log.start_time, log.end_time)>=info.duration then 1 else 0 end )/count(*),3) avg_comp_play_rate # case when 后面不用加括号,不然会报错 from tb_user_video_log log left join tb_video_info info on log.video_id=info.video_id where log.end_time like '...