0
点赞
收藏
分享

微信扫一扫

【Mysql】刷题

程序小小黑 2022-02-02 阅读 45
mysql

SQL33 找出每个学校GPA最低的同学

select a.device_id, a.university uni, a.gpa from user_profile a inner join (select min(gpa) min_gpa, university from user_profile group by university) b on a.university = b.university and a.gpa = b.min_gpa order by uni asc;

刚开始使用子查询:

 select ... from ... gpa = (select min(gpa) from ... group by ...) and university = (selectuniversity from ... group by ....);

报错:子查询返回的row > 1。

之后改为in,返回的结果出现两个清华大学,依旧有错。

最终改为了本文最开始的子表join形式。

举报

相关推荐

0 条评论