1、2、3、4、5、6、7、8、9、10、11、12、13、14、15、16、17、
查询“CS”系所有学生的学号和姓名。
Slelect sno,sname from student where sdept =’CS’查询所有姓“刘”的学生的信息。
Select * from student where sname like ‘刘%’查询年龄在18至20岁之间的学生信息
。
Select * from student where sage between 18 and 20 查询不在“CS”系也不在“MA”系的学生的所有信息。Select * from student where sdept not in (‘CS’,’MA’) 查询“CS”系所有学生的平均年龄。
Select avg(sage) from student where sdept like ‘CS’查询课程名是以“系统”结尾的课程信息。Select * from course where cname like ‘%系统’查询先行课为“6”号课程的课程信息。Select * from course where cpno=6
查询间接先行课为“5”号课程的课程号及课程名。
Select c1.cno,c1.cname from c c1,c c2 where c1.cpno=c2.cno and c2.cpno=5 Select cno ,cname from course where cpno in (select cno from course where cpno=5)
18、19、20、21、22、23、
查询没有先行课的课程名。
Select cname from course where cpno is null 查询选修了“1”号课程的学生选课信息。Select * from sc where cno=1
查询成绩为90分以上的学生姓名和课程名。
Select sname ,cname from s,c,sc where s.sno=sc.sno and c.cno=sc.cno and grade>=90
24、25、26、
查询被选修了的课程号及课程名。
Select cno ,cname from course where cno in (Select distinct(cno ) from sc) Select cno ,cname from course where exists (select * from sc where course.cno=sc.cno)
—
27、28、29、
查询没有选修课程的学生学号及姓名。
Select sno,sname from s where sno not in (select distinct(sno) from sc) Select sno ,sname from s where not exists(select * from sc where s.sno=sc.sno)
30、31、
查询没有选修“1”号课程的学生姓名。
Select sname from s where sno not in (select distinct(sno) from sc where cno=1)
32、Select sname from s where not exists (select * from sc where sc.sno=s.sno and sc.cno=1)
33、34、
查询既选修了“数据结构”又选修了“操作系统”的学生姓名。
Select sname from s.c,sc where s.sno=sc.sno and c.cno=sc.cno and cname=’数据结构’
35、Select sname from s where sno in (select sno from sc where cno=(slect cno from c where cname=’数据结构’) and sno in (select sno from sc where cno=(select cno from c where cname=’操作系统’)))
36、Select sname from s where sno in (select sno from sc sc1,sc sc2 where sc1.sno=sc2.sno and sc1.cno=(slect cno from c where cname=’数据结构’) and sc2.cno=(select cno from c where cname=’操作系统’))
37、38、39、
查询既选修了“2”号又选修了“4”号课程的学生学号。
Select sno from sc where cno=2 and sno in(select sno from sc where cno=4) Select sno from sc sc1,sc sc2 where sc1.sno=sc2.sno and sc1.cno=2 and sc2.cno=4
40、41、42、43、
查询选修了“2”号或“4”号课程的学生学号。Select sno from sc where cno=2 or cno=4
查询至少选修了“95002”学生所选课程的学生学号。
Select scx.sno from sc scx where not exists (select * from sc scy where scy.sno=’95002’ and not exists (select * from sc scz where scy.cno=scz.cno and scz.sno=scx.sno))
44、45、
欢迎下载
查询至少选修了一门其间接先行课为“7”号课程的学生姓名。
Select sname from s where sno in(Select sno from sc where cno in (Select c1.cno from c c1,c c1 where c1.cpno=c2.cno and c2.cpno=7))
2
—
46、47、
查询选修了所有课程的学生姓名。
Select sname from s where not exists (select * from c where not exists (select * from sc where c.cno=sc.cno and sc.sno=s.sno))
48、49、
查询“李勇”同学所选课程的平均成绩。
Select avg(grade) from sc where sno =(Select sno from s where sname =’李勇’)
50、51、
查询“操作系统”这门课的最高分及最低分。
Select max(grade),min(grade) from sc where cno=(select cno from course where cname =’操作系统’)
52、53、
查询“数据结构”这门课的选课人数。
Select count(sno) from sc where cno =(select cno from course where cname=’数据结构’)
54、55、
查询“CS”系的所有学生的学号、姓名、课程名及成绩。
Select sno,sname,cname,grade from s,sc,c where s.sno=sc.sno and c.cno=sc.cno and sdept=’CS’
56、查询“CS”系选修课程的成绩在90分以上的所有女生的姓名、课程名和成绩。
57、Select sname,cname,grade from s,sc,c where s.sno=sc.sno and c.cno=sc.cno and sdept=’CS’ and grade >=90 and ssex like ‘女’
欢迎下载3
因篇幅问题不能全部显示,请点此查看更多更全内容