目前3个表 sc,score,student
题目为:查询每个学生已获得的学分(成绩及格即得相应课程的学分)
已经做到这一步:
对于这题,现在需要把刘洋的ctime加起来,下面是解决方案:
select sname,SUM(ctime)as totalctime
from
( select sname,ctime
from
(select sname,student.sno,sc.cno
from student
left outer join sc
on student.sno=sc.sno and sc.score>60)as r1,course
where r1.cno=course.cno
) as r2
group by sname
解决了~~