已知关系模式: S(sno,sname)学生关系,sno为学号,sname为姓名 C(cno,cname)课程关系,cno为课程号,cname为课程名,cteacher为任课老师。 SC(sno,cno,scgrade)为选课关系,s cgrade为成绩 4)列出“1”号课成绩比“2”号课成绩高的所有学生的学号及其“1”号课和“2”号课的成绩。
时间: 2024-04-08 17:31:41 浏览: 123
SQL查询练习题(ppt文档).ppt
SELECT SC1.sno, SC1.scgrade AS '1号课成绩', SC2.scgrade AS '2号课成绩'
FROM SC SC1
INNER JOIN SC SC2 ON SC1.sno = SC2.sno
WHERE SC1.cno = '1' AND SC2.cno = '2' AND SC1.scgrade > SC2.scgrade;
阅读全文