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

求分析一个查询,这个感觉挺难的
数据库有这么一张表选课表 SC(sno,cno,grade) 属性分别指学号,课程号,分数 
求实现以下查询的SQL语句

-至少选修了7号学生选修的全部课程的学生号码  
PS:如果可以的话,不用exists最好..

------解决方案--------------------
select a.sno
from sc a,sc b
where a.sno <> 7
and b.sno = 7
and a.cno = b.cno
group by a.sno
having count(1) = (select count(1) from sc where sno = 7)