题解 | #各个视频的平均完播率#
各个视频的平均完播率
http://www.nowcoder.com/practice/96263162f69a48df9d84a93c71045753
有点简单粗暴,其实就是计算完播数量,再算出总的视频播放数,相除即可~
select
distinct a.video_id,
round(count(distinct case when timestampdiff(SECOND,start_time,end_time)>=b.duration then uid ELSE NULL end)/count(distinct uid),3)
from
tb_user_video_log a
left join
tb_video_info b
on a.video_id = b.video_id
group by a.video_id