龙空技术网

mysql 练习题答案

编程鲍老师 111

前言:

如今小伙伴们对“mysql查询成绩为85或者86的记录”都比较重视,小伙伴们都需要了解一些“mysql查询成绩为85或者86的记录”的相关文章。那么小编在网上搜集了一些有关“mysql查询成绩为85或者86的记录””的相关文章,希望小伙伴们能喜欢,兄弟们快快来学习一下吧!

```

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

select Sname,Ssex,Class from student

```

```

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

select distinct Depart from teacher

```

```

3、 查询Student表的所有记录。

select * from student

```

```

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

select * from Score where Degree between 60 and 80

```

```

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

select * from Score where Degree in(85,86,88)

```

```

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

select * from Student where class='95031' or Ssex='女'

```

```

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

select * from student order by class desc

```

```

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

select * from Score order by cno asc,degree desc

```

```

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

select count(*) from student where class='95031'

```

```

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

select Sno,Cno from Score order by Degree desc limit 0,1

```

```

11、查询每门课的平均成绩。

select Cno,avg(degree) from Score group by Cno

```

```

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

select avg(Degree) from score where Cno like '3%' and group by Cno having count(*)>=5

```

```

13、查询分数大于70,小于90的Sno列。

select Sno from Score where degree>70 and degree<90

```

```

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

select Sname, Cno,Degree from Score , student where Score.Sno=student.Sno

```

```

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

select Sno,Cname,Degree from Score , Course where Score.Cno=Course.Cno

```

```

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

select Sname,Cname,Degree from student,course,score where student.Sno=score.Sno and course.Cno=score.Cno

join .. on 写法:

select Sname,Cname,Degree from student join score on student.Sno=score.Sno join course on course.Cno=score.Cno

```

```

17、查询“95033”班学生的平均分。

select avg(degree) as 'class=95033' from Score where Sno in (select Sno from Student where Class='95033' )

```

```

18、假设使用如下命令建立了一个grade表:

create table grade(low int(3),upp int(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列。

select Sno,Cno,rank from Score,grade where degree between low and upp

```

```

19、查询成绩高于学号为“109”、课程号为“3-105”的成绩的所有记录。

Select * from score where degree>(select degree from Score where Sno='109' and Cno='3-105' )

```

```

20、查询和学号为108、101的同学同年出生的所有学生的Sno、Sname和Sbirthday列。

select sno,sname,sbirthday from student where year(sbirthday) = (select year(sbirthday) from student where sno='108')

select sno,sname,sbirthday from student where year(sbirthday) = (select year(sbirthday) from student where sno='101')

```

```

21、查询“张旭“教师任课的学生成绩。

select Sno,degree from score,Course where score.Cno=Course.Cno and Course.Tno= (select Tno from Teacher where Tname='张旭' )

select degree from score where Cno in (select cno from course where Tno= (select Tno from Teacher where Tname='张旭' ) )

```

```

22、查询95033班和95031班全体学生的记录。

select * from student where class in ('95033','95031')

```

```

23、查询存在有85分以上成绩的课程Cno.

select Cno from score where degree>85

```

```

24、查询出“计算机系“教师所教课程的成绩表。

select * from course where cno in (select cno from course where tno in (select tno from teacher where Depart='计算机系'))

```

```

25、查询成绩比该课程平均成绩低的同学的成绩表。

select * from score a where degree < (select avg(degree) from score b where b.cno=a.cno)

```

```

26、查询所有任课教师的Tname和Depart.

select Tname,Depart from Teacher where tno in (select tno from course )

```

```

27、查询至少有2名男生的班号。

select class from student where ssex='男' group by class having count(*)>1

```

```

28、查询Student表中不姓“王”的同学记录。

select * from Student where Sname not like '王%%'

```

```

29、查询Student表中每个学生的姓名和年龄。

select Sname, year(now())-year(sbirthday) from Student

```

```

30、查询Student表中最大和最小的Sbirthday日期值。

select Max(Sbirthday ),Min(Sbirthday ) from Student

```

```

31、以班号和年龄从大到小的顺序查询Student表中的全部记录。

select * from Student order by class desc, Sbirthday

```

```

32、查询“男”教师及其所上的课程。

select Tname,Cname from course,teacher where course.tno= teacher.tno and teacher.Tsex='男'

```

```

33、查询最高分同学的Sno、Cno和Degree列。

select Sno,Cno,Degree from score where degree=(select max(degree) from score)

```

标签: #mysql查询成绩为85或者86的记录