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

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

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

with t1 as (
select level,
case when score>=90 then '优' 
     when score>=75 then '良'
     when score>=60 then '中'
     else '差' end as score_grade
from(
select level,score
from user_info
inner join exam_record using(uid)
where score is not null
)t
),
t2 as 
(
    select level,count(*) as lvsm
    from t1 
    group by level
)
select level,score_grade,round(sum(1/lvsm),3) as ratio
#或者select level,score_grade,round(count(*)/lvsm,3) as ratio
from t1
inner join t2 using(`level`)
group by level,score_grade
order by level desc,ratio desc

全部评论

相关推荐

喜欢吃蛋糕仰泳鲈鱼是我的神:字节可以找个hr 给你挂了,再放池子捞
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务