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

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

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

#方法一: 嵌套子查询
select
    level,
    count(level) level_cnt
from (
    select
    t1.exam_id,
    level,
    tag
from (
    select
        exam_id,
        level
    from exam_record er
    left join user_info ui on er.uid= ui.uid
    where er.submit_time is not null
    and er.score > 80
)t1
left join examination_info ei on t1.exam_id = ei.exam_id
where tag = 'SQL'
)t2
group by level
order by level_cnt desc;

#方法二:
select
    ui.level,
    count(ui.uid) level_cnt
from user_info ui where uid in (
    select
        er.uid
    from examination_info ei 
    join exam_record er using(exam_id) 
    where ei.tag = 'SQL' and er.submit_time is not null  and er.score > 80
)group by level
order by level_cnt desc;

全部评论

相关推荐

点赞 评论 收藏
分享
自学java狠狠赚一...:骗你点star的,港卵公司,记得把star收回去
点赞 评论 收藏
分享
有担当的灰太狼又在摸...:零帧起手查看图片
点赞 评论 收藏
分享
06-26 10:08
门头沟学院 C++
北京Golang实习,一个月4700,吃住都不报,公司位置在海淀。请问友友怎么看呢?如果要租房的话有什么建议吗
码农索隆:租房肯定是合租了,剩下的钱,差不多够正常吃饭了,看看能不能学到东西吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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