当前位置:Gxlcms > 数据库问题 > 数据库SQL语句练习题

数据库SQL语句练习题

时间:2021-07-01 10:21:17 帮助过:69人阅读

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 * from score order by degree desc

技术分享

 

【无关子查询】

select sno,cno from score where degree=(select max(degree) from score)

技术分享

 

数据库SQL语句练习题

标签:函数   9.png   val   tween   ima   学生   datetime   技术分享   助教   

人气教程排行