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

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

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

select uid, start_month, total_cnt, complete_cnt
from
(select t.uid uid, date_format(start_time, '%Y%m') start_month, count(t.uid) total_cnt, count(score) complete_cnt, rank() over (partition by t.uid order by date_format(start_time, '%Y%m') desc) r
from
(select uid, count(uid) - count(score) incomplete_cnt, count(uid) total_cnt,
percent_rank() over (order by ((count(uid) - count(score)) / count(uid))) incomplete_rate
from exam_record r
left join examination_info i
on r.exam_id = i.exam_id
where tag = 'SQL'
group by uid) t
left join user_info u
on t.uid = u.uid
left join exam_record e
on t.uid = e.uid
where (level = 6 or level = 7) and incomplete_rate >= 0.5
group by t.uid, start_month) a
where r <= 3
order by uid, start_month;

使用percent_rank()排名窗口函数筛选未完成率较高的前50%用户。

全部评论

相关推荐

WillingLing:查看图片
点赞 评论 收藏
分享
04-06 11:24
已编辑
太原学院 C++
真烦好烦真烦:感觉不太对劲,这种主动加微信的一般都是坑,要小心辨别
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务