问答题

某学校的学生成绩管理数据库的关系模式如下:
S(SNO,SNAME,SEX);
C(CNO,CNAME);
SC(SNO,CNO,SCORE)  
其中,
S表示学生表,各字段依次为学号,姓名,性别;
C表示为课程表,各字段依次为课程号,课程名;
SC表示成绩表,各字段依次为学号,课程号和分数。

使用SQL语句,查询选修“计算机网络”课程的学生姓名和分数,并按分数降序排序。

【参考答案】

select s.sname,sC.score from s,c,sc where s.sno=sC.sno and C.cno=sC.cno and C.cname=‘计算机网络’ order by sC.score desc 或者  
select s.sname,sC.score from s,sc where s.sno=sC.sno and sC.cno in (select cno from c where C.cname=‘计算机网络’) order by sC.score desc 或者 
select s.sname,sC.score from s,sc where s.sno=sC.sno and exists (select 1 from c where C.cname=‘计算机网络’ and sC.cno=C.cno) order by sC.score desc