18、假设使用如下命令建立了一个grade表:
create table grade(low number(3,0),upp number(3),rank char(1));
insert into grade values(90,100,’A’);
insert into grade values(80,89,’B’);
insert into grade values(70,79,’C’);
insert into grade values(60,69,’D’);
insert into grade values(0,59,’E’);
commit;
现查询所有同学的Sno、Cno和rank列。
19、查询选修“3-105”课程的成绩高于“109”号同学成绩的所有同学的记录。
20、查询score中选学一门以上课程的同学中分数为非最高分成绩的记录。
31、查询所有教师和同学的name、sex和birthday.
32、查询所有“select distinct from女”教师和“女”同学的name、sex和birthday.
33、查询成绩比该课程平均成绩低的同学的成绩表。
create table grade(low number(3,0),upp number(3),rank char(1));
insert into grade values(90,100,’A’);
insert into grade values(80,89,’B’);
insert into grade values(70,79,’C’);
insert into grade values(60,69,’D’);
insert into grade values(0,59,’E’);
commit;
现查询所有同学的Sno、Cno和rank列。
19、查询选修“3-105”课程的成绩高于“109”号同学成绩的所有同学的记录。
20、查询score中选学一门以上课程的同学中分数为非最高分成绩的记录。
31、查询所有教师和同学的name、sex和birthday.
32、查询所有“select distinct from女”教师和“女”同学的name、sex和birthday.
33、查询成绩比该课程平均成绩低的同学的成绩表。
34、查询所有任课教师的Tname和Depart.
35 查询所有未讲课的教师的Tname和Depart.
36、查询至少有2名男生的班号。
37、查询Student表中不姓“王”的同学记录。
38、查询Student表中每个学生的姓名和年龄。
39、查询Student表中最大和最小的Sbirthday日期值。
40、以班号和年龄从大到小的顺序查询Student表中的全部记录。
41、查询“男”教师及其所上的课程。
42、查询最高分同学的Sno、Cno和Degree列。
43、查询和“李军”同性别的所有同学的Sname.
44、查询和“李军”同性别并同班的同学Sname.
45、查询所有选修“计算机导论”课程的“男”同学的成绩表
35 查询所有未讲课的教师的Tname和Depart.
36、查询至少有2名男生的班号。
37、查询Student表中不姓“王”的同学记录。
38、查询Student表中每个学生的姓名和年龄。
39、查询Student表中最大和最小的Sbirthday日期值。
40、以班号和年龄从大到小的顺序查询Student表中的全部记录。
41、查询“男”教师及其所上的课程。
42、查询最高分同学的Sno、Cno和Degree列。
43、查询和“李军”同性别的所有同学的Sname.
44、查询和“李军”同性别并同班的同学Sname.
45、查询所有选修“计算机导论”课程的“男”同学的成绩表
参考答案
查询‘3-105’号课程的平均分。
11、select avg(degree)as 课程平均分 from score where cno='3-105';
11、select avg(degree)as 课程平均分 from score where cno='3-105';
查询Score表中至少有5名学生选修的并以3开头的课程的平均分数。
12、select cno,avg(degree) from score where cno like'3%'group by cno having count(*) >5;
12、select cno,avg(degree) from score where cno like'3%'group by cno having count(*) >5;
查询最低分大于70,最高分小于90的Sno列。
13、select Sno from score group by Sno having min(degree)>70 and max(degree)<90;
13、select Sno from score group by Sno having min(degree)>70 and max(degree)<90;
查询所有学生的Sname、Cno和Degree列。
14、select student.Sname,score.Cno,score.degree from student,score where student.Sno=score.Sno;
14、select student.Sname,score.Cno,score.degree from student,score where student.Sno=score.Sno;
查询所有学生的Sno、Cname和Degree列。
15、select x.Sno,y.Cname,x.degree from score x,course y where x.Cno=y.Cno;
15、select x.Sno,y.Cname,x.degree from score x,course y where x.Cno=y.Cno;
查询所有学生的Sname、Cname和Degree列。
16、select x.Sname,y.Cname,z.degree from student x,course y,score z where x.Sno=z.Sno and z.Cno=y.Cno;
查询“95033”班所选课程的平均分。
17、select y.Cno,avg(y.degree) from student x,score y where x.Sno=y.Sno and x.class='95033'group by yo;
18、select Sno,Cno,rank from score,grade where degree between low and upp order by rank;
19、select x.Cno,x.Sno,x.degree from score x,score y
where xo='3-105' and x.degree>y.degree and y.sno='109'and yo='3-105';
20、
1,查询成绩非本科最高 select * from score b where degree <(select max(degree) from score a where ao=bo);
2,查询成绩非本科最高并且选2门以上的学生的成绩:
17、select y.Cno,avg(y.degree) from student x,score y where x.Sno=y.Sno and x.class='95033'group by yo;
18、select Sno,Cno,rank from score,grade where degree between low and upp order by rank;
19、select x.Cno,x.Sno,x.degree from score x,score y
where xo='3-105' and x.degree>y.degree and y.sno='109'and yo='3-105';
20、
1,查询成绩非本科最高 select * from score b where degree <(select max(degree) from score a where ao=bo);
2,查询成绩非本科最高并且选2门以上的学生的成绩:
查询成绩高于学号为“109”、课程号为“3-105”的成绩的所有记录。
21、select xo,x.Sno,x.degree from score x,score y where x.degree>y.degree and y.sno='109'and yo='3-105';
select cno,sno,degree from score where degree >(select degree from score where sno='109' and cno='3-105')
select cno,sno,degree from score where degree >(select degree from score where sno='109' and cno='3-105')
查询和学号为108的同学同年出生的所有学生的Sno、Sname和Sbirthday列
22、select sno,sname,sbirthday from student where to_char(sbirthday,'yyyy')=(select to_char(sbirthday,'yyyy') from student where sno='108');
22、select sno,sname,sbirthday from student where to_char(sbirthday,'yyyy')=(select to_char(sbirthday,'yyyy') from student where sno='108');
查询“张旭“教师任课的学生成绩。
23、select cno,sno,degree from score where cno=(select xo from course x,teacher y =y.tno ame='张旭');
23、select cno,sno,degree from score where cno=(select xo from course x,teacher y =y.tno ame='张旭');
查询选修某课程的同学人数多于5人的教师姓名。
24、select tname from teacher where tno in( from course x,score y where xo=yo group having )>5);
24、select tname from teacher where tno in( from course x,score y where xo=yo group having )>5);
查询95033班和95031班全体学生的记录
25、select * from student where class in('95033','95031');
25、select * from student where class in('95033','95031');
查询存在有85分以上成绩的课程Cno.
26、select distinct cno from score where degree in (select degree from score where degree>85);
26、select distinct cno from score where degree in (select degree from score where degree>85);
查询出“计算机系“教师所教课程的成绩表。
27、select * from score where cno in(select xo from course x,teacher y =x.tno and y.depart='计算机系');
27、select * from score where cno in(select xo from course x,teacher y =x.tno and y.depart='计算机系');
查询“计算机系”与“电子工程系“不同职称的教师的Tname和Prof。
28、select tname,prof from teacher where depart='计算机系' and prof not in (select prof from teacher where depart='电子工程系');
28、select tname,prof from teacher where depart='计算机系' and prof not in (select prof from teacher where depart='电子工程系');
查询选修编号为“3-105“课程且成绩至少高于选修编号为“3-245”的同学的Cno、Sno和Degree,并按Degree从高到低次序排序。
29、select * from score where cno='3-105' and degree>all (select degree from score where cno='3-245')order by degree desc;
查询选修编号为“3-105”且成绩高于选修编号为“3-245”课程的同学的Cno、Sno和Degree.
30、select * from score where cno='3-105' and degree>all(select degree from score where cno='3-245');
31、select tname,tsex,tbirthday from teacher
union select sname,ssex,sbirthday from student;
32、select tname,tsex,tbirthday from teacher where tsex='女'
union select sname,ssex,sbirthday from student where ssex='女';
33、select * from score a where degree<(select avg(degree)
from score b where ao=bo);
30、select * from score where cno='3-105' and degree>all(select degree from score where cno='3-245');
31、select tname,tsex,tbirthday from teacher
union select sname,ssex,sbirthday from student;
32、select tname,tsex,tbirthday from teacher where tsex='女'
union select sname,ssex,sbirthday from student where ssex='女';
33、select * from score a where degree<(select avg(degree)
from score b where ao=bo);
查询所有任课教师的Tname和Depart.
34、select tname,depart from teacher a where exists
(select * from course b =b.tno);
34、select tname,depart from teacher a where exists
(select * from course b =b.tno);
35、select tname,depart from teacher a where not exists
(select * from course b =b.tno);
36、select class from student where ssex='男'group by class having count(*)>=2;
37、select * from student where sname not like'王_';
38、select sname as 姓名,(to_char(sysdate,'yyyy')-to_char(sbirthday,'yyyy')) as 年龄 from student
39、select sname,sbirthday as 最大 from student where sbirthday =(select min (sbirthday) from student)
union select sname,sbirthday as 最小 from student where sbirthday =(select max(sbirthday) from student)
40、select class,sname,sbirthday from student order by class desc,sbirthday;
41、ame,yame from teacher x,course y =y.tno and x.tsex='男';
42、select * from score where degree=(select max(degree)from score);
43、select sname from student where ssex=(select ssex from student where sname='李军');
(select * from course b =b.tno);
36、select class from student where ssex='男'group by class having count(*)>=2;
37、select * from student where sname not like'王_';
38、select sname as 姓名,(to_char(sysdate,'yyyy')-to_char(sbirthday,'yyyy')) as 年龄 from student
39、select sname,sbirthday as 最大 from student where sbirthday =(select min (sbirthday) from student)
union select sname,sbirthday as 最小 from student where sbirthday =(select max(sbirthday) from student)
40、select class,sname,sbirthday from student order by class desc,sbirthday;
41、ame,yame from teacher x,course y =y.tno and x.tsex='男';
42、select * from score where degree=(select max(degree)from score);
43、select sname from student where ssex=(select ssex from student where sname='李军');
44、select sname from student where ssex=(select ssex from student where sname='李军') and class=(select class from student where sname='李军');
45、select * from score where sno in(select sno from student where ssex='男') and cno=(select cno from course
where cname='计算机导论');
45、select * from score where sno in(select sno from student where ssex='男') and cno=(select cno from course
where cname='计算机导论');
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论