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

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

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

虽然搞不懂,但还是自己敲了一遍,搬砖的一天

select er.uid,
date_format(er.start_time,'%Y%m') as start_month,
count(er.id) as total_cnt,
sum(case when er.submit_time is not null then 1 else 0 end) as complete_cnt
from 
(select *,
dense_rank() over(partition by uid order by date_format(start_time,'%Y%m') desc) as month_rank from exam_record)er
left join user_info on er.uid=user_info.uid
where user_info.level in (6,7) and er.month_rank<=3 and er.uid in 
(select b.uid
from 
(select a.*,
row_number() over(order by a.incomplete_rate desc,a.uid asc) as rank_num
from
(select uid,
sum(case when submit_time is null then 0 else 1 end)as incomplete_cnt,
count(id) as total_cnt,
sum(case when submit_time is null then 0 else 1 end)/count(id) as incomplete_rate
from exam_record
group by uid)a)b left join user_info u on b.uid=u.uid
where b.rank_num>(select count(distinct uid)/2 from exam_record) and  level in (6,7))
group by 1,2
order by 1,2

全部评论

相关推荐

头像
05-16 11:16
已编辑
东华理工大学 Java
牛客737698141号:盲猜几十人小公司,庙小妖风大,咋不叫她去4️⃣呢😁
点赞 评论 收藏
分享
后来123321:别着急,我学院本大二,投了1100份,两个面试,其中一个还是我去线下招聘会投的简历,有时候这东西也得看运气
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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