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

各个视频的平均完播率

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

 

select
  video_id,
  round(
    count(
      case
        when F = 'Y' then 1
      end
    ) / count(F),
    3
  ) R
from
  (
    select
      uid,
      lg.video_id,
      if(end_time - start_time >= duration, 'Y', 'N') F
    from
      tb_user_video_log lg
      left join (
        select
          video_id,
          duration
        from
          tb_video_info
      ) d on lg.video_id = d.video_id
    where
      year(start_time) = 2021
  ) b
group by
  video_id
order by
  R desc

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务