#需求:计算各类视频的平均播放进度,将进度大于60%的类别输出
#输出:tag,avg_play_progress(平均播放进度)
#要求:播放进度保留两位小数,倒序输出;播放进度=播放时长/视频时长*100%,播放时长大于视频时长时,播放进度均记为100%
#思路:先得到播放进度的if,计算后筛选60%的输出
select tag,concat(round(avg(
if(timestampdiff(second,start_time,end_time)>duration,1,timestampdiff(second,start_time,end_time)/duration)
)*100,2),'%') avg_play_progress
from tb_user_video_log join tb_video_info using(video_id)
group by tag
having avg_play_progress>60
order by avg_play_progress desc