题解 | #各个视频的平均完播率#
各个视频的平均完播率
http://www.nowcoder.com/practice/96263162f69a48df9d84a93c71045753
求 2021年的 每个视频 完播率: (结束时间-开始时间)=duration的视频 / 总的视频 降序
select video_id,
round(avg(if(timestampdiff(second,vl.start_time,vl.end_time) >= vi.duration,1,0)),3) as avg_comp_play_rate
#round(count(if(timestampdiff(second,vl.start_time,vl.end_time) >= vi.duration,1,null)) / count(vl.video_id),3) as avg_comp_play_rate
from tb_user_video_log vl
join tb_video_info vi using(video_id)
where year(vl.start_time) = 2021
group by vl.video_id #vl.id
order by avg_comp_play_rate desc;