9、 查询“95031”班的学生人数。
select count(1) from student where sclass='95031'
10、 查询Score表中的最高分的学生学号和课程号。(子查询或者排序)
select s.sno,s.cno from score s where degree in(select max(degree) from score) ;
select * from (select * from score order by degree desc) where rownum=1;
11、 查询每门课的平均成绩。
select cno,avg(degree),count(1) from score t group by cno;
12、查询Score表中至少有5名学生选修的并以3开头的课程的平均分数。
select cno,avg(degree),count(cno) from score where cno like '3%'group by cno having count(cno)>=5;
13、查询分数大于70,小于90的Sno列。
select sno from student s where s.sno in(select sno from score where degree between 70 and 90);
14、查询所有学生的Sname、Cno和Degree列。
select Sname,cno,degree from score s,student t where t.sno=s.sno;
15、查询所有学生的Sno、Cname和Degree列。
select cname,sno,degree from course c,score s where s.cno=c.cno ;
16、查询所有学生的Sname、Cname和Degree列。
select cname,sname,degree from course c,score s,student t where s.cno=c.cno and t.sno=s.sno;
17、 查询“95033”班学生的平均分。
select avg(degree) from score s where s.sno in(select sno from student where sclass='95033');
18、 假设使用如下命令建立了一个grade表:
create table grade(low number(3),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’)
现查询所有同学的Sno、Cno和rank列。
create table grade
(
low number(3),
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');
select sno,cno,rank from grade g,score s where s.degree>g.low and s.degree<g.upp;