题解 | #未完成率较高的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

全部评论

相关推荐

kabuu:问多了怕遇到聪明人坑不了了,说不定里面很坑呢,还是相信自己的选择吧
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
11-21 11:29
已编辑
斯卡蒂味的鱼汤:知道你不会来数马,就不捞你😂最近数马疯狂扩招,招聘要求挺低的,你能力肯定够,应该就是因为太强了,知道你不会来才不捞你
投递腾讯云智研发等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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