美文网首页
【SQL】4.test练习题及答案(1)

【SQL】4.test练习题及答案(1)

作者: 一曈 | 来源:发表于2017-06-05 10:26 被阅读81次

1、 查询Student表中的所有记录的Sname、Ssex和Class列

select sname,ssex,class from student;
题目1

2、 查询教师所有的单位即不重复的Depart列

select distinct depart from teacher;
题目2

3、 查询Student表的所有记录

select * from student;
题目3

4、 查询Score表中成绩在60到80之间的所有记录

select * from score where degree between 60 and 80;
题目4

5、 查询Score表中成绩为85,86或88的记录

select * from score where degree in (85,86,88);
题目5

6、 查询Student表中“95031”班或性别为“女”的同学记录

select * from student where class='95031' or ssex='女';
题目6

7、 以Class降序查询Student表的所有记录。

select * from student order by class desc;
题目7

8、 以Cno升序、Degree降序查询Score表的所有记录。

select * from score order by cno,degree desc;
题目8

9、 查询“95031”班的学生人数。

select count(sname) from student where class='95031';
题目9

10、查询Score表中的最高分的学生学号和课程号。

select sno,cno from score where degree=(select max(degree) from score);
题目10

11、查询‘3-105’号课程的平均分。

select avg(degree) from score where cno='3-105';
题目11

12、查询Score表中至少有5名学生选修的并以3开头的课程的平均分数。

 select avg(degree),cno from score
 where cno like '3%'
 group by cno
 having count(cno)>=5
题目12

13、查询最低分大于70,最高分小于90的Sno列。

select sno from score
group by sno
having max(degree)<90 and min(degree)>70;
题目13

14、查询所有学生的Sname、Cno和Degree列。

方法一
select s.sname,sc.cno,sc.degree from student s
join score sc on s.sno=sc.sno;
方法二
 select a.sname,b.cno,b.degree from student a,score b
 where a.sno=b.sno;
题目14

15、查询所有学生的Sno、Cname和Degree列。

方法一
select c.cname,sc.sno,sc.degree from course c
join score sc on c.cno=sc.cno;
方法二
select sc.sno,c.cname,sc.degree from score sc,course c
where sc.cno=c.cno;
题目15

16、查询所有学生的Sname、Cname和Degree列。

方法一
select s.sname,c.cname,sc.degree from student s
join (course c,score sc)
on s.sno=sc.sno and c.cno=sc.cno;
方法二
 select s.sname,c.cname,sc.degree from student s
 join score sc on sc.sno=s.sno
 join course c on c.cno=sc.cno;
题目16

17、查询“95033”班所选课程的平均分。

 select avg(degree) from score sc
 join student s
 on sc.sno = s.sno
 where s.class='95033';
题目17

相关文章

  • 【SQL】4.test练习题及答案(1)

    1、 查询Student表中的所有记录的Sname、Ssex和Class列 2、 查询教师所有的单位即不重复的De...

  • SQL练习50题

    50道SQL练习题及答案与详细分析 1.查询" 01 "课程比" 02 "课程成绩高的学生的信息及课程分数 因为需...

  • sql 经典50题

    50道SQL练习题及答案与详细分析 网上流传较广的50道SQL训练,奋斗了不知道多久终于写完了。前18道题的难度依...

  • 50道SQL练习题及答案

    网上流传这这样的50道练习题,以下是我的解法,仅供各位联系和参考 数据表介绍 --1.学生表Student(SId...

  • 【SQL】18.test3练习题及答案(1)

    1、查询“c001”课程比“c002”课程成绩高的所有学生的学号 2、查询平均成绩大于60 分的同学的学号和平均成...

  • sqlzoo练习答案

    这是关于在一个SQL学习网站的练习题答案记录:SQL教程 SQL基础 由一些简单的查询开始 这里的默认表格为WOR...

  • 【SQL】5.test练习题及答案(2)

    18、假设使用如下命令建立了一个grade表: create table grade(low number(3,...

  • 【SQL】16.test2练习题及答案

    1.查询"01"课程比"02"课程成绩高的学生的信息及课程分数 2.查询平均成绩大于等于60分的同学的学生编号、学...

  • SQL练习题-1

    员工表结构: 部门表结构: 部门员工表结构: 部门经理表结构: 薪资表结构: 1.查找最晚入职员工的所有信息 分析...

  • 【SQL】19.test3练习题及答案(2)

    27、1981 年出生的学生名单(注:Student 表中Sage 列的类型是number) 28、查询每门课程的...

网友评论

      本文标题:【SQL】4.test练习题及答案(1)

      本文链接:https://www.haomeiwen.com/subject/gmcifxtx.html