1、查询每个系的最高成绩
select x.sno,sdept,grade from student x,sc
where x.sno = sc.sno and
grade =(select max(grade) from sc,student
where sc.sno=student.sno and sdept=x.sdept)
select x.sno,sdept,grade from student x,sc
where x.sno = sc.sno and
grade in(select max(grade) from sc,student
where sc.sno=student.sno and sdept=x.sdept group by sdept)
//用了相关子查询,这两个结果都是对的,但这里第二个的group by sdept是不是多余了啊?所以不写也是对的。谢谢指导。另外还有其他写法吗?
SQL 相关子查询问题 分组问题
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-