各位,帮个小忙,不胜感激!
现在又有一个难题:
courses表(Cno,Cname,creditHour)
reports表(Sno,Cno,Grade)
dapt表(DeptNo,DeptName)
Students表(Sno,Snaem ,DeptName,StartDate,CreditHours)
上面是四个表和表中的字段,现在要查询:
C语言的最高分还有对应的姓名和学号
(结果是一个表)
谢谢大侠!
------解决方案--------------------
Select S.Sno as 学号, S.Sname as 姓名, C.Cname as 课程名, T.最高分
from Courses as C inner join
(select cno, max(grade) as 最高分 from reports group by cno) as T
on C.Cno = T.Cno
inner join reports as R on R.Cno = T.Cno and R.Grade = T.最高分
inner join Students as S on S.Sno = R.Sno
where C.Cname = 'C语言'
以后作业要自己做,不然永远学不会