select video_id, round(完播次数/播放次数,3) avg_comp_play_rate from ( select a.video_id, count(if(watch_time>=duration,id,null)) 完播次数, count(id) 播放次数 from (select id,video_id, timestampdiff(second,start_time,end_time) watch_time from tb_user_video_log ...