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

select Sname,Ssex,t.sclass from STUDENT t

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

select distinct t.depart from TEACHER t

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

select * from STUDENT t

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

select * from SCORE t where degree > 60 and degree < 80

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

select * from SCORE t where degree = 85 or degree = 86 or degree = 88

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

select * from STUDENT t where t.sclass=9305 or t.ssex='女'

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

select * from STUDENT t order by t.sclass desc

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

select * from SCORE t order by t.cno asc,t.degree desc

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

select count(*) from STUDENT t where t.sclass=95031

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

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

select avg(t.degree) from SCORE t group by t.cno   --分组

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

select t.cno,avg(t.degree) from SCORE t where t.cno like '3%' group by t.cno   --分组加在后面

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

1select count(t.sno) from SCORE t where t.degree>60 or t.degree<90

2select t.sno from SCORE t where t.degree between 60 and 90

第一种为什么不行

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

select c.sname,t.cno,t.degree from student c,score t where c.sno=t.sno

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

select a.sno,b.cname,c.degree from student a,course b,score c where b.cno=c.cno and c.sno=a.sno

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

select a.sname,b.cname,c.degree from student a,course b, score c where a.sno=c.sno and b.cno=c.cno

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

select avg(degree) from student a,score b where a.class='95033' and b.sno=a.sno

20、查询score中选学多门课程的同学中分数为非最高分成绩的记录。

select t.sno from SCORE t where t.degree< (select max(t.degree) from SCORE t) group by sno having count(cno)>1

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

select * from score where cno='3-105' and degree>(select max(degree) from score where sno = '109' )

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

select sno,sname,sbirthday from student t where t.sbirthday= (select sbirthday from student where sno='108')23、查询“张旭“教师任课的学生成绩。

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

select * from STUDENT t,SCORE s where t.sclass=95033 or t.sclass=95031

_学生选课数据库SQL语句练习题的更多相关文章

  1. 20_学生选课数据库SQL语句练习题

    一.            设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四个表的结构分别如表1-1的表(一)~表( ...

  2. 学生选课数据库SQL语句练习题

    一.            设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四个表的结构分别如表1-1的表(一)~表( ...

  3. 20_学生选课数据库SQL语句练习题1

    25.查询95033班和95031班全体学生的记录. select * from STUDENT t,SCORE s where t.sclass=95033 or t.sclass=95031 26 ...

  4. (10.09作业)学生选课数据库SQL语句练习题

  5. 学生选课数据库SQL语句45道练习题整理及mysql常用函数(20161019)

    学生选课数据库SQL语句45道练习题: 一.            设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四 ...

  6. SQL Server T—SQL 学生选课数据库SQL语句考试题(45道题)

    题目  设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四个表的结构分别如表1-1的表(一)~表(四)所示,数据如表1 ...

  7. 选课数据库SQL语句练习题

    表(一)Student (学生表) 属性名 数据类型 可否为空 含 义 Sno varchar (20) 否 学号(主码) Sname varchar (20) 否 学生姓名 Ssex varchar ...

  8. 学生选课数据库MySQL语句练习题45道

    1. 查询Student表中的所有记录的Sname.Ssex和Class列. select Sname,Ssex,Class from Student;2. 查询教师所有的单位即不重复的Depart列 ...

  9. 数据库SQL语句练习题

    一.            设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四个表的结构分别如表1-1的表(一)~表( ...

随机推荐

  1. lambda 表达式 比较时间大小

    data.Orderdetails.Where(r => r.orderstatus == id && DateTime.Compare((DateTime)r.OrderTim ...

  2. redis命令总结

     Redis命令总结 redis 127.0.0.1:6379> info  #查看server版本内存使用连接等信息 redis 127.0.0.1:6379> client list  ...

  3. spring-aop学习

     SpringAOP学习 author:luojie 1.  AOP中的基本概念 AOP的通用术语,并非spring java所特有.很遗憾AOP的术语不是特别的直观.但如果让Spring java来 ...

  4. Openlayers+Geoserver(一):项目介绍以及地图加载

           项目验收完,趁着事情不是很多,对这个项目进行梳理.我主要负责地图模块,网站其他模块主要有两个,一个是报表,主要是100多张报表,技术没有难度,主要是工作量的问题.另一个是数据的校验,就是 ...

  5. MySQL入门手册

    本文内容摘自MySQL5.6官方文档,主要选取了在实践过程中所用到的部分文字解释,力求只摘录重点,快速学会使用MySQL,本文所贴代码地方就是我亲自练习过的代码,凡本文没有练习过的代码都没有贴在此处, ...

  6. nginx简易安装

    yum -y install perl-ExtUtils-Embed ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx ...

  7. MAT-Java内存分析工具

    对Mat工具的详细介绍,引用博文:http://my.oschina.net/biezhi/blog/286223 下载地址:http://www.eclipse.org/mat/downloads. ...

  8. Java Environment Setting

    As a non-Java developer, I am quit stuck in Java environment setting because I am not familiar with ...

  9. Java多线程理解

    首先说一下进程和线程的区别 进程:是计算机运用程序实例,拥有独立的内存空间和数据(猜测内存堆应该是作用的进程上),一个进程包含多个子线程,不同进程相互独立: 线程:cpu执行的基本单位,拥有独立的寄存 ...

  10. 搭建一个SSH项目框架的步骤

    1.导入jar包(38个) 2.配置文件 applicationContext,xml (beans.xml) (数据源.LocalSessionFactoryBean.事务管理器.事务通知.AOP切 ...