-
答案:
-
--1、 查询Student 表中的所有记录的Sname、Ssex 和Class 列。 select Sname,Ssex,Class from Student
-
--2、 查询教师所有的单位即不重复的Depart 列。 select Depart from TEACHER group by Depart
-
--3、 查询Student 表的所有记录。 select * from Student
-
--4、 查询Score 表中成绩在60 到80 之间的所有记录。' select * from Score where DEGREE between 60 and 80
-
--5、 查询Score 表中成绩为85,86 或88 的记录。 select * from Score where DEGREE in (85,86,88)
-
--6、 查询Student 表中“95031”班或性别为“女”的同学记录。 select * from Student where Class='95031' and Ssex='女'
-
--7、 以Class 降序查询Student 表的所有记录。 select * from Student order by Class Desc
-
--8、 以Cno 升序、Degree 降序查询Score 表的所有记录。 select * from Score order by Cno,Degree Desc
-
--9、 查询“95031”班的学生人数。 select Class,count(*) [人数] from Student group by Class having Class='95031'
-
--10、查询Score 表中的最高分的学生学号和课程号。 select Sno,Cno from Score where Degree in ( select Max(Degree) from Score )
-
--11、查询‘3-105’号课程的平均分。 select Cno,avg(Degree) [平均分] from Score group by Cno having Cno='3-105'
-
--12、查询Score 表中至少有5 名学生选修的并以3 开头的课程的平均分数。 select Cno,count(*) [选课人数],avg(Degree) [平均分] from Score group by Cno having Cno like '3%' and count(*)>=5
-
--13、查询最低分大于70,最高分小于90 的Sno 列。 select Sno,max(degree) [最高分],min(degree) [最低分] from Score group by Sno having min(degree)>70 and max(degree)<90
-
--14、查询所有学生的Sname、Cno 和Degree 列。 select A.Sname,B.Cno,B.Degree from Student A,Score B where A.Sno=B.Sno
-
--15、查询所有学生的Sno、Cname 和Degree 列。 select B.Sno,A.Cname,B.Degree from Course A,Score B where A.Cno=B.Cno
-
--16、查询所有学生的Sname、Cname 和Degree 列。 select A.Sname,B.Cname,C.Degree from Student A,Course B,Score C where A.Sno=C.Sno and B.Cno=C.Cno
-
--17、查询“95033”班所选课程的平均分。 select Cno,avg(Degree) [平均分] from Score where Sno in ( select Sno from Student where Class='95033' ) group by Cno
-
--18、查询选修“3-105”课程的成绩高于“109”号同学成绩的所有同学的记录。 select * from Student where Sno in ( select SNO from Score where Cno='3-105' and Degree> ( select Degree from Score where Cno='3-105' and Sno='109' ))
-
--19、查询score 中选学一门以上课程的同学中分数为非最高分成绩的记录。 select * from ( select * from Score where Sno in ( select Sno from Score group by Sno having count(*)>1 )) A inner join ( select Cno,max(Degree) maxdegree from Score group by Cno ) B on A.Cno=B.Cno where A.Degree<B.maxdegree
-
--20、查询“张旭“教师任课的学生成绩。 select * from Score where CNO in ( select CNO from Course where TNO in ( select TNO from Teacher where Tname='张旭' ))
-
--21、查询选修某课程的同学人数多于5 人的教师姓名。 select Tname from Teacher where TNO in ( select TNO from Course where CNO in ( select CNO from Score group by Cno having count(*)>5 ))
-
--22、查询存在有85 分以上成绩的课程Cno. select Cno from Score group by Cno having max(degree)>=85
-
--23、查询出“计算机系“教师所教课程的成绩表。 select * from Score where CNO in ( select CNO from Course where TNO in ( select TNO from Teacher where Depart='计算机系' ))
-
--24、查询“计算机系”与“电子工程系“不同职称的教师的Tname 和Prof。 select Tname,Prof from Teacher where Depart='计算机系' and Prof not in ( select Prof from Teacher where Depart='电子工程系' ) or Depart='电子工程系' and Prof not in ( select Prof from Teacher where Depart='计算机系' )