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

各个视频的平均完播率

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;
全部评论

相关推荐

深夜书店vv:腾讯是这样的,去年很多走廊都加桌子当工区
点赞 评论 收藏
分享
06-18 13:28
已编辑
门头沟学院 Web前端
爱睡觉的冰箱哥:《给予你300的工资》,阴的没边了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务