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

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

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

Select uid, start_month, count(start_month) total_cnt, count(submit_month) complete_cnt
from 

(Select er.uid, tag, date_format(start_time, '%Y%m') start_month, date_format(submit_time, '%Y%m') submit_month 
from 
exam_record er 
left join examination_info ei on er.exam_id = ei.exam_id 
left join user_info ui on er.uid = ui.uid 
where level in ('6','7') ) t1

where 
t1.uid in (
    Select uid
    from 
        (Select uid, total_cnt , incomplete_cnt, ROW_NUMBER() over(order by incomplete_cnt/total_cnt ) as incomplete_rank, count(1)over() as num
        from 
            (Select er.uid as uid, count(start_time) as total_cnt, count(submit_time) as incomplete_cnt
            from (exam_record er 
            left join examination_info ei on er.exam_id = er.exam_id 
            left join user_info ui on er.uid = ui.uid)
            where tag = "SQL"
            group by er.uid) t2 ) t3 
    where incomplete_rank <= (num + 1) / 2
) and 
t1.start_month in (Select start_month from (Select date_format(start_time, '%Y%m') as start_month, DENSE_RANK() over(partition by uid order by date_format(start_time, '%Y%m') desc) as start_month_rank from exam_record) t4 where start_month_rank <= 3)


group by t1.uid, t1.start_month
order by uid,start_month

全部评论

相关推荐

2024-11-26 00:10
门头沟学院 Java
chenxinxu:现在招聘的都学精了,你光学点数据库和中间件做个应用型项目人家看不上,你得有点可以“吹水”的高谈阔论的“高大上”的玩意,比如写点什么“基于分布式 Raft 共识性算法的XXX”balabala 的,然后做了什么详尽的 benchmark 怎么优化的吞吐率性能之类的,看起来就是科研论文研究领域。现在人不都这样吗,他知道的知识都是白菜,他不知道的领域都是高端,找点让大部分人看起来高端的玩意写
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务