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

各个视频的平均完播率

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

select 
c.id as  video_id,
ROUND(ifnull((end1.e/c.a),0) ,3)as avg_comp_play_rate
from (
    select
        tb_video_info.video_id as id,
        count(tb_video_info.id) as a
    from
        tb_user_video_log
        left join tb_video_info on tb_video_info.video_id = tb_user_video_log.video_id
        where   
        tb_user_video_log.start_time>= '2021-01-01'
    group by
        tb_video_info.id
) as c left join 
( select
    tb_user_video_log.video_id as id ,
        count(tb_video_info.id) as e
    from
        tb_user_video_log
        left join tb_video_info on tb_video_info.video_id = tb_user_video_log.video_id
        where    TIMESTAMPDIFF(second,tb_user_video_log.start_time,tb_user_video_log.end_time) >= duration 
        and tb_user_video_log.start_time >= "2021-01-01"
         group by
         tb_video_info.video_id
) end1  on c.id=end1.id
order by avg_comp_play_rate desc

#我是菜鸡#
全部评论
哎 用了一个小时才写出来。太菜了。
点赞 回复 分享
发布于 2023-02-14 11:11 浙江

相关推荐

不愿透露姓名的神秘牛友
11-26 15:46
已编辑
字节国际 电商后端 24k-35k
点赞 评论 收藏
分享
我是小红是我:学校换成中南
点赞 评论 收藏
分享
评论
1
收藏
分享
牛客网
牛客企业服务