/*计算各类视频的平均播放进度,将进度大于60%的类别输出。
解题:1.播放进度计算: 播放时长/视频时长*100% concat(()*100,'%')
2.当播放时长大于视频时长时,播放进度均记为100%。
注意: 比较数值大小时,先不要使用concat
*/
select a.tag,
concat(round(a.process*100,2),'%') as avg_process
from
    (
    select i.tag
    ,avg(case when timestampdiff(second,start_time,end_time) > i.duration then 1
             else timestampdiff(second,start_time,end_time)/i.duration 
            end)as process
    from tb_user_video_log t
    left join tb_video_info i 
    on t.video_id = i.video_id
    group by i.tag
    having process>0.6
    )a
    order by 2 desc