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

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

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

全部评论

相关推荐

不愿透露姓名的神秘牛友
昨天 10:39
一个证都没&nbsp;我能填什么
程序员小白条:别人有,你为什么没有,还是这个道理,社会就是比较,竞争,淘汰,你要安逸,那么就要做好淘汰的准备
点赞 评论 收藏
分享
06-20 19:40
中原工学院 Java
网络存储:十几天不会让你拉人办卡就结束了吧?
点赞 评论 收藏
分享
宇算唯航:目测实缴资本不超100W的小公司
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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