select c.t, concat(round(avg(c.p)*100,2),'%') as per from (select a.uid, a.video_id, b.tag as t, if((timestampdiff(second,a.start_time,a.end_time)/b.duration)>1, 1, (timestampdiff(second,a.start_time,a.end_time)/b.duration)) as p from tb_user_video_log a left join tb_video_info b on a.video_id = b.video_id) c group by c.t having replace(per,'%','') > 60 order by per desc

  1. 百分比的显示,使用round 和 concat函数
  2. 筛选百分比,先使用replace函数去掉%