题解 | #各用户等级的不同得分表现占比#
各用户等级的不同得分表现占比
https://www.nowcoder.com/practice/ebff819fd38c46db8a42dfe43ca7b33a
with c as ( select level,a.*,count(*) over (partition by level) sum from user_info right join( select uid,score,case when score<60 then '差' when score>=60 and score<75 then '中' when score>=75 and score<90 then '良' when score>=90 then '优' else '差' end as score_grade from ( select uid,exam_id,score from exam_record where submit_time is not null )b )a using(uid) ) select level,score_grade,round(count(*)/sum,3) rate from c group by level,score_grade order by level desc,rate desc