题解 | #未完成率较高的50%用户近三个月答卷情况#

未完成率较高的50%用户近三个月答卷情况

https://www.nowcoder.com/practice/3e598a2dcd854db8b1a3c48e5904fe1c

这个题找了好久的bug,一直不知道问题出在哪里,后来发现自己算的是完成率,在筛选的时候却把它当成了未完成率
select
  uid,
  date_format(start_time, '%Y%m') as start_month,
  count(start_time) as total_cnt,
  count(submit_time) as complete_cnt
from (
    select
      uid,
      percent_rank() over (
        order by
          count(submit_time) / count(*)
      ) as rank_rk
    from
      exam_record
      join examination_info using(exam_id)
    where
      tag = 'SQL'
    group by
      uid
  ) as t2 left join
  (
    select
      *,
      dense_rank() over(
        partition by uid
        order by
          date_format(start_time, '%Y%m'desc
      ) as rank_r
    from
      exam_record
    where
      uid in (
        select
          uid
        from
          user_info
        where
          level in (67)
      )
  ) as t1 using(uid)
where
  rank_rk <=0.5
  and rank_r <= 3
group by
  uid,
  date_format(start_time, '%Y%m')
order by
  uid,
  date_format(start_time, '%Y%m')


全部评论

相关推荐

就在我现在公司的隔壁每天经过都唏嘘不已(就是羡慕)什么时候可以到这里上班啊
柯基在debug:从大学毕业投简历到现在了,应届的时候我都面到终面了,现在工作四年了连简历初筛都过不了了
投递莉莉丝游戏等公司7个岗位 >
点赞 评论 收藏
分享
深夜书店vv:腾讯是这样的,去年很多走廊都加桌子当工区
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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