题解 | #获取每个部门中当前员工薪水最高的相关信息#
平均播放进度大于60%的视频类别
http://www.nowcoder.com/practice/c60242566ad94bc29959de0cdc6d95ef
个人感觉此题有局限性:如果一个tag映射多部video_id,每部剧的duration时间不一致的话,那答案就大错特错了 所以应该先group by video_id ,再进行 group by tag 比较严谨
SELECT tag,concat(avg_1,'%') avg_play_progress
FROM
(SELECT tag,round(AVG(if((TIMESTAMPDIFF(second,start_time,end_time)/duration)>1,1,(TIMESTAMPDIFF(second,start_time,end_time)/duration)))*100,2)
AS avg_1
FROM tb_user_video_log JOIN tb_video_info USING(video_id)
GROUP BY tag
HAVING avg_1 > 60) t1
ORDER BY avg_play_progress desc