![](https://csdnimg.cn/release/download_crawler_static/11227792/bg5.jpg)
https://blog.csdn.net/ganquanzhong
5
WHERE score > 60);
------------------------------------------------------------------
--10、查询所有课程成绩大于 60 分的同学的学号、姓名;
--思路:与第 9 题相同
--given answer
select sno,sname from student
where sno not in (select distinct sno from sc where score < 60);
--my answer
SELECT sno, sname
FROM student
WHERE sno NOT IN (SELECT DISTINCT sno
FROM sc
WHERE score < 60);
--11、查询没有学全所有课的同学的学号、姓名;
--思路:NOT + 子查询
--given answer
select student.sno, student.sname
from student, sc
where student.sno = sc.sno
group by student.sno, student.sname
having count(sc.cno) < (select count(cno) from course);
--my answer
SELECT sno, sname
FROM student
WHERE sno NOT IN (SELECT sno
FROM sc, course AS c
WHERE sc.cno = c.cno
GROUP BY sc.sno
HAVING COUNT(sc.cno) = (SELECT COUNT(cno)
FROM course));
--------------------------------------------------------------
--12、查询至少有一门课程 与 学号为 1 的同学所学课程 相同的同学的学号和姓名;
--思路:联结 or 子查询
--given answer
select distinct a.sno, a.sname
from student a, sc b
where a.sno <> 1 and a.sno=b.sno and
b.cno in (select cno from sc where sno = 1);