文档库 最新最全的文档下载
当前位置:文档库 › 数据库练习答案1

数据库练习答案1

1、 查询Student表中的所有记录的Sname、Ssex和Class列。
2、 查询教师所有的单位即不重复的Depart列。
3、 查询Student表的所有记录。
4、 查询Score表中成绩在60到80之间的所有记录。
5、 查询Score表中成绩为85,86或88的记录。
6、 查询Student表中“95031”班或性别为“女”的同学记录。
7、 以Class降序查询Student表的所有记录。
8、 以Cno升序、Degree降序查询Score表的所有记录。
9、 查询“95031”班的学生人数。
10、查询Score表中的最高分的学生学号和课程号。
11、查询‘3-105’号课程的平均分。
12、查询Score表中至少有5名学生选修的并以3开头的课程的平均分数。
13、查询最低分大于70,最高分小于90的Sno列。
14、查询所有学生的Sname、Cno和Degree列。
15、查询所有学生的Sno、Cname和Degree列。
16、查询所有学生的Sname、Cname和Degree列。
17、查询“95033”班所选课程的平均分。
18、查询选修“3-105”课程的成绩高于“109”号同学成绩的所有同学的记录。

1、select sname,ssex,class from student
2、select distinct depart from teacher
3、select * from student
4、select * from score where degree between 60 and 80
5、select * from score where degree in (85,86,88)
6、select * from student where class='95031'or Ssex='女'
7、select * from student order by class desc
8、select * from score order by cno asc ,degree desc
9、select count(sno) from student where class='95031'
10、select * from score where degree=(select max(degree) from score)
11、select avg(degree) from score where cno='3-105'
12、select avg(DEGREE) from score where cno like '3%' GROUP BY cno HAVING count(cno) > 4
13、select sno from score GROUP BY sno HAVING min(DEGREE) > 70 and MAX(degree)
14、select x.sname,https://www.wendangku.net/doc/259042596.html,o,y.degree from student x,score y where x.SNO = y.SNO
15、select x.Sno,https://www.wendangku.net/doc/259042596.html,ame,x.degree from score x,course y where https://www.wendangku.net/doc/259042596.html,o=https://www.wendangku.net/doc/259042596.html,o
16、select x.Sname,https://www.wendangku.net/doc/259042596.html,ame,z.degree from student x,course y,score z where x.Sno=z.Sno and https://www.wendangku.net/doc/259042596.html,o=https://www.wendangku.net/doc/259042596.html,o
17、select avg(y.DEGREE) from student x, score y WHERE x.SNO = y.SNO and x.CLASS = '95033' GROUP BY https://www.wendangku.net/doc/259042596.html,O
18、select x.* from score x, score y where https://www.wendangku.net/doc/259042596.html,O = '3-105' and x.DEGREE > y.DEGREE and https://www.wendangku.net/doc/259042596.html,O = '3-105' and y.SNO = '109'


1、查询成绩高于学号为“109”、课程号为“3-105”的成绩的所有记录。
2、查询“张旭“教师任课的学生成绩
3、查询选修某课程的同学人数多于5人的教师姓名
4、查询95033班和95031班全体学生的记录
5、查询存在有85分以上成绩的课程Cno
6、查询出“计算机系“教师所教课程的成绩表
7、查询选修编号为“3-105“课程且成绩至少高于选修编号为“3-245”的同学的Cno、Sno和Degree,并按Degree

从高到低次序排序
8、查询选修编号为“3-105”且成绩高于选修编号为“3-245”课程的同学的Cno、Sno和De
gree
9、查询成绩比该课程平均成绩低的同学的成绩表
10、查询所有任课教师的Tname和Depart
11、查询至少有2名男生在同一个班级的班号
12、查询Student表中不姓“王”的同学记录
13、以班号和年龄从大到小的顺序查询Student表中的全部记录
14、查询“男”教师及其所上的课程
15、查询每门课程最高分同学的Sno、Cno和Degree列
16、查询和“李军”同性别的所有同学的Sname
17、查询和“李军”同性别并同班的同学Sname
18、查询所有选修“计算机导论”课程的“男”同学的成绩表

1、查询成绩高于学号为“109”、课程号为“3-105”的成绩的所有记录。
select x.* from score x, score y where x.DEGREE > y.DEGREE and y.SNO = '109' and https://www.wendangku.net/doc/259042596.html,O = '3-105'

select x.* from score x where x.degree > (select y.degree from score y where y.sno = '109' and https://www.wendangku.net/doc/259042596.html,o = '3-105')
2、查询“张旭“教师任课的学生成绩
select s.DEGREE from score s, teacher t, course c where https://www.wendangku.net/doc/259042596.html,O=https://www.wendangku.net/doc/259042596.html,O and t.TNO=c.TNO and t.TNAME='张旭'
3、查询选修某课程的同学人数多于5人的教师姓名
select t.TNAME from teacher t,score s,course c where t.TNO = c.TNO and https://www.wendangku.net/doc/259042596.html,O = https://www.wendangku.net/doc/259042596.html,O GROUP BY https://www.wendangku.net/doc/259042596.html,O HAVING count(https://www.wendangku.net/doc/259042596.html,O) > 5
4、查询95033班和95031班全体学生的记录
select * from student where class in ('95033','95031')

select * from student where class='95033' or class='95031'
5、查询存在有85分以上成绩的课程Cno
select DISTINCT cno from score where degree > 85
6、查询出“计算机系“教师所教课程的成绩表
select s.* from score s, teacher t, course c where t.DEPART='计算机系' and t.TNO = c.TNO and https://www.wendangku.net/doc/259042596.html,O = https://www.wendangku.net/doc/259042596.html,O;
7、查询选修编号为“3-105“课程且成绩至少高于选修编号为“3-245”的同学的Cno、Sno和Degree,并按Degree从高到低次序排序
select x.* from score x where https://www.wendangku.net/doc/259042596.html,O='3-105' and x.DEGREE>(select min(y.DEGREE) from score y where https://www.wendangku.net/doc/259042596.html,o='3-245') ORDER BY x.DEGREE desc
8、查询选修编号为“3-105”且成绩高于选修编号为“3-245”课程的同学的Cno、Sno和Degree
select x.* from score x where https://www.wendangku.net/doc/259042596.html,O='3-105' and x.DEGREE>(select max(y.DEGREE) from score y where https://www.wendangku.net/doc/259042596.html,o='3-245')
9、查询成绩比该课程平均成绩低的同学的成绩表
select x.* from score x where x.DEGREE < (select avg(y.DEGREE) from score y where https://www.wendangku.net/doc/259042596.html,O = https://www.wendangku.net/doc/259042596.html,o)
10、查询所有任课教师的Tname和Depart
select t.TNAME,t.DEPART from teacher t,course c where t.TNO = c.TNO
11、查询至少有2名男生在同一个班级的班号
select class from student where ssex = '男' GROUP BY class HAVING

count(sno)>1
12、查询Student表中不姓“王”的同学记录
select * from student where sname not like'王%'
13、以班号和年龄从大到小的顺序查询Student表中的全部记录
select * from student ORDER BY class desc, SBIRTHDAY asc
14、查询“男”教师及其所上的课程
select t.*,c.* from
teacher t, course c where t.TSEX='男' and c.TNO = t.TNO
15、查询每门课程最高分同学的Sno、Cno和Degree列
select s.* from score s where s.DEGREE = (select max(x.DEGREE) from score x where https://www.wendangku.net/doc/259042596.html,O = https://www.wendangku.net/doc/259042596.html,o)
16、查询和“李军”同性别的所有同学的Sname
select x.SNAME from student x where x.SSEX = (select y.SSEX from student y where y.sname='李军')
17、查询和“李军”同性别并同班的同学Sname
select x.SNAME from student x where x.SSEX = (select y.SSEX from student y where y.sname='李军' and x.CLASS = y.class)
18、查询所有选修“计算机导论”课程的“男”同学的成绩表
select s.* from score s,student x,course c where x.SSEX='男' and https://www.wendangku.net/doc/259042596.html,AME='计算机导论' and https://www.wendangku.net/doc/259042596.html,O = https://www.wendangku.net/doc/259042596.html,O and x.SNO = s.SNO

相关文档