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

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

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

select 
c.level level,
c.score_grade score_grade,
format(count(1)/c.level_cn,3) ratio
from 
(
    select
b.uid,
b.exam_id,
b.score,
a.level,
case when b.score<60 then '差'
when b.score>=60 and b.score<75 then '中'
when b.score>=75 and b.score<90 then '良'
else  '优' end score_grade,
count(level) OVER(PARTITION BY level) level_cn
from 
exam_record b
left join user_info a
on a.uid=b.uid
where b.submit_time is not null
) c
group by c.level,c.score_grade
order by level desc,ratio desc

学习了 count(a) over (partition by b)

全部评论

相关推荐

10-21 00:37
已编辑
门头沟学院 C++
小浪_Coding:你问别人,本来就是有求于人,别人肯定没有义务免费回答你丫, 有点流量每天私信可能都十几,几十条的,大家都有工作和自己的事情, 付费也是正常的, 就像你请别人搭把手, 总得给人家买瓶水喝吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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