日期:2014-05-17  浏览次数:20526 次

SQL嵌套查询
求至少选修了学号为“95002”的学生所选修全部课程的学生学号和姓名


求C1课程的成绩高于范林军的学生学号和成绩



这两个如何用SQL语句查找啊?
求帮助!!!
SQL

------解决方案--------------------
1,select 学号,姓名 from tb a where not exists(select 1 from tb b a.课程<>b.课程 and b.学='95002')

2,select 学号,姓名,成绩 from tb a
    where not exists(select 1 from tb b where a.课程=b.课程 and b.课程='C1' and a.成绩<b.成绩) and a.课程='C1'