题解 | #各用户等级的不同得分表现占比#
各用户等级的不同得分表现占比
https://www.nowcoder.com/practice/ebff819fd38c46db8a42dfe43ca7b33a
select
level,
score_grade,
round(count(score_grade)/sum(count(score_grade))over(partition by level),3) ratio
from
(select
uid,
level,score,submit_time,
if(score>=90,'优',if(score>=75,'良',if(score>=60,'中','差'))) score_grade
from exam_record
left join user_info using(uid)
)t
where submit_time is not null
group by level,score_grade
order by level desc,ratio desc