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

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

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

with t as(
    select uid,
           level,
          (1 - count(submit_time) / count(start_time)) as incomplete_rate,
          percent_rank() over(order by (1 - count(submit_time) / count(start_time)) desc) ranking
    from exam_record
    join examination_info ei
    using(exam_id)
    join user_info
    using(uid)
    where tag = 'SQL'
    group by uid
)



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,
        start_time,
        submit_time,
		dense_rank() over(partition by uid order by date_format(start_time,'%Y%m') desc) as recent
		from exam_record er
		join examination_info ei
		using(exam_id)
		where uid in(
				select uid     
				from t
				where ranking <= 0.5
				and (level = 6 or level = 7)
		)
)t2
where recent <=3
group by uid,start_month
order by uid,start_month

全部评论

相关推荐

Allen好Iverson:我看牛客都是20-30k的 这个3.9k爆出来有点,哈哈哈哈
点赞 评论 收藏
分享
🔌插電的小米大冰箱:很喜欢放牛,因为牛不会在我翻过第四座山后跟我说第一座山的草好吃
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务