题解 | #各用户等级的不同得分表现占比#

各用户等级的不同得分表现占比

https://www.nowcoder.com/practice/ebff819fd38c46db8a42dfe43ca7b33a

with tb as(
select score,level, 
count(level) over(partition by level) as answer_cnt,  #添加记录每个等级用户答卷数量
case when score>= 90 then '优'
     when score<90 and score >=75 then '良'
     when score<75 and score >=60 then '中'
     else '差' end as score_grade
from exam_record 
left join user_info using(uid)
where score is not null)

select level, score_grade, 
round(count(level)  / answer_cnt ,3)as ratio
from tb
group by level,score_grade
order by level desc,ratio desc

全部评论

相关推荐

点赞 评论 收藏
分享
这算盘打的
程序员小白条:都这样的,都是潜规则,你自己说可以实习一年就行了,实习可以随便跑路的
点赞 评论 收藏
分享
头顶尖尖的程序员:我也是面了三四次才放平心态的。准备好自我介绍,不一定要背熟,可以记事本写下来读。全程控制语速,所有问题都先思考几秒,不要急着答,不要打断面试官说话。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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