题解 | #作答试卷得分大于过80的人的用户等级分布#

作答试卷得分大于过80的人的用户等级分布

https://www.nowcoder.com/practice/5bc77e3a3c374ad6a92798f0ead4c744

select level,count(distinct r.uid) 'level_cnt'
from exam_record r left join user_info i on r.uid = i.uid
where 
r.exam_id in 
(
    select exam_id
    from examination_info
    where tag = 'SQL'
)
and r.score > 80
group by i.level
order by level_cnt desc, level desc

除了需要按照level_cnt降序排序,还得按照level排序。因为会产生level_cnt重复的情况

#悬赏#
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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