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

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

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

这个题比较简单,没什么说的。

select
    c.level,
    c.score_grade,
    format(count(1)/max(levelNum),3) as ratio
from 
(

    select
        b.level,
        (case when a.score >= 90 then '优'
        when a.score >=75 then '良'
        when a.score >= 60 then '中'
        else '差' end) as score_grade,
        count(1) over(partition by b.level) as levelNum
    from exam_record a join user_info b on a.uid = b.uid and a.submit_time is not null
) c

group by c.level,c.score_grade

order by c.level desc,ratio desc

全部评论

相关推荐

斑驳不同:还为啥暴躁 假的不骂你骂谁啊
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务