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;
现查询所有同学的SnoCnorank列。
19、查询选修3-105”课程的成绩高于109”号同学成绩的所有同学的记录。
20、查询score中选学一门以上课程的同学中分数为非最高分成绩的记录。

31、查询所有教师和同学的namesexbirthday.
32、查询所有select distinct from教师和同学的namesexbirthday.
33、查询成绩比该课程平均成绩低的同学的成绩表。
34、查询所有任课教师的TnameDepart.
35  查询所有未讲课的教师的TnameDepart.
36、查询至少有2名男生的班号。
37、查询Student表中不姓的同学记录。
38、查询Student表中每个学生的姓名和年龄。
39、查询Student表中最大和最小的Sbirthday日期值。
40、以班号和年龄从大到小的顺序查询Student表中的全部记录。
41、查询教师及其所上的课程。
42、查询最高分同学的SnoCnoDegree列。
43、查询和李军同性别的所有同学的Sname.
44、查询和李军同性别并同班的同学Sname.
45、查询所有选修计算机导论课程的同学的成绩表
参考答案

查询‘3-105’号课程的平均分。
11select avg(degree)as 课程平均分 from score where cno='3-105';
查询Score表中至少有5名学生选修的并以3开头的课程的平均分数。
12select cno,avg(degree) from score where cno like'3%'group by cno having  count(*) >5;
查询最低分大于70,最高分小于90Sno列。
13select Sno from score group by Sno having min(degree)>70 and max(degree)<90;
查询所有学生的SnameCnoDegree列。
14select student.Sname,score.Cno,score.degree from student,score where student.Sno=score.Sno;
查询所有学生的SnoCnameDegree列。
15select x.Sno,y.Cname,x.degree from score x,course y where x.Cno=y.Cno;
查询所有学生的SnameCnameDegree列。
16select x.Sname,y.Cname,z.degree from student x,course y,score z where x.Sno=z.Sno and z.Cno=y.Cno;
查询95033”班所选课程的平均分。
17select y.Cno,avg(y.degree) from student x,score y where x.Sno=y.Sno and x.class='95033'group by yo;
18select Sno,Cno,rank from score,grade where degree between low and upp order by rank;
19select 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”的成绩的所有记录。
21select 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')
查询和学号为108的同学同年出生的所有学生的SnoSnameSbirthday
22select sno,sname,sbirthday from student where to_char(sbirthday,'yyyy')=(select to_char(sbirthday,'yyyy') from student where sno='108');
查询张旭教师任课的学生成绩。
23select cno,sno,degree from score where cno=(select xo from course x,teacher y =y.tno ame='张旭');
查询选修某课程的同学人数多于5人的教师姓名。
24select tname from teacher where tno in( from course x,score y where xo=yo group having )>5);
查询95033班和95031班全体学生的记录
25select * from student where class in('95033','95031');
查询存在有85分以上成绩的课程Cno.
26select distinct cno from score where degree in (select degree from score where degree>85);
查询出计算机系教师所教课程的成绩表。
27select * from score where cno in(select xo from course x,teacher y =x.tno and y.depart='计算机系');
查询计算机系电子工程系不同职称的教师的TnameProf
28select tname,prof from teacher where depart='计算机系' and prof not in (select prof from teacher where depart='电子工程系');
查询选修编号为3-105“课程且成绩至少高于选修编号为3-245”的同学的CnoSnoDegree,并按Degree从高到低次序排序。
29select * 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”课程的同学的CnoSnoDegree.
30select * from score where cno='3-105' and degree>all(select degree from score where cno='3-245');
31select tname,tsex,tbirthday from teacher
union select sname,ssex,sbirthday from student;
32select tname,tsex,tbirthday from teacher where tsex=''
union select sname,ssex,sbirthday from student where ssex='';
33select * from score a where degree<(select avg(degree)
from score b where ao=bo);
查询所有任课教师的TnameDepart.
34select tname,depart from teacher a where exists
(select * from course b =b.tno);
35select tname,depart from teacher a where not exists
(select * from course b =b.tno);
36select class from student where ssex=''group by class having count(*)>=2;
37select * from student where sname not like'_';
38select sname as 姓名,(to_char(sysdate,'yyyy')-to_char(sbirthday,'yyyy')) as 年龄 from student
39select 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) 
40select class,sname,sbirthday from student order by class desc,sbirthday;
41ame,yame from teacher x,course y =y.tno and x.tsex='';
42select * from score where degree=(select max(degree)from score);
43select sname from student where ssex=(select ssex from student where sname='李军');
44select sname from student where ssex=(select ssex from student where sname='李军') and class=(select class from student where sname='李军');
45select * from score where sno in(select sno from student where ssex='') and cno=(select cno from course
where cname='计算机导论');

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。