题解 | #各个视频的平均完播率#

各个视频的平均完播率

http://www.nowcoder.com/practice/96263162f69a48df9d84a93c71045753

select video_id,
    round(完播次数/播放次数,3) avg_comp_play_rate
from (
    select a.video_id,
        count(if(watch_time>=duration,id,null)) 完播次数,
        count(id) 播放次数
    from (select id,video_id,
            timestampdiff(second,start_time,end_time) watch_time
        from tb_user_video_log
        where year(start_time) = 2021) a 
    left join
        (select video_id, duration
        from tb_video_info) b
    on a.video_id = b.video_id
    group by a.video_id
) c
order by avg_comp_play_rate desc;
全部评论

相关推荐

点赞 评论 收藏
分享
10-09 22:05
666 C++
找到工作就狠狠玩CSGO:报联合国演讲,报电子烟设计与制造
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务