文档介绍:sql****题及答案
LT
题
 
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、假设使用如下命令建立了一个grade表:
create table grade(low numeric(3,0),upp numeric(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列。
19、查询选修“3-105”课程的成绩高于“109”号同学成绩的所有同学的记录。
20、查询score中选学一门以上课程的同学中分数为非最高分成绩的记录。
21、查询成绩高于学号为“109”、课程号为“3-105”的成绩的所有记录。
select distinct depart from teacher;
* from student;
4.     
select * from score where degree between 60 and 80;  
or 
select * from score where degree>=60 and degree<=80;
5.  
select * from score where degree in (85,86,88); 
or
select * from score where degree=85 or degree=86 or degree=88;
* from student where class=95031 or ssex='女';
* from student order by class desc;
8.       
select * from score order by cno asc,degree desc;
or
select * from score order by cno,degree desc;
9.     
select count(*) from student where class=95031;
or
select count(sno) from student where class=95031;
10. select Sno as '学号',cno as '课程号', degree as '最高分' from score where degree=(select max(degree) from score);
11. select avg(degree) from score where cno='3-105';
12.      
select cno,avg(degree) from score where cno like '3%' group by cno having count(sno)>5;
or      
select cno,avg(degree) from score where cno like '3%' group by cno having count(*)>5;
sno from