2、列出同時選修了'數(shù)學(xué)’和'數(shù)據(jù)庫’的學(xué)生學(xué)號、姓名;
select student.sno,sname
from student,sc
where cno in (select cno from course
where cname='數(shù)學(xué)')and sc.sno=student.sno
intersect
select student.sno,sname
from student,sc
where cno in (select cno from course
where cname='數(shù)據(jù)庫')and sc.sno=student.sno
3、查詢?nèi)鄙俪煽兊乃袑W(xué)生的詳細(xì)情況;
select * from student,sc where Grade is null and student.sno=sc.sno
查詢?nèi)鄙俪煽兊乃袑W(xué)生的學(xué)號姓名;
select student.sno sname from student,sc where Grade is null and student.sno=sc.sno
4、查詢與'李勇’ 年齡相同的所有學(xué)生的信息;
select * from student
where sage =(select sage from student where sname='李勇') and sname <> '李勇’
查詢與'楊磊’年齡不相同的所有學(xué)生的信息;
select * from student
where sage <>(select sage from student where sname='楊磊')
7、按照“學(xué)號,姓名,所在院系,不及格課程門數(shù)”的順序列出學(xué)生有課程不及格的情況。
select student.sno,sname,sdept,count(grade) 不及格門數(shù) from student,sc
where student.sno=sc.sno and grade<60 group by student.sno,sname,sdept
9、查詢只被一名學(xué)生選修的課程的課程號;
select cno from sc group by Cno having COUNT(sno)=1
聯(lián)系客服