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. Git常用

    创建本地库 mkdir [dirname] cd [dirname] git init 1.创建项目目录 2.进入目录 3.git初始化 [dirname]为自己取的文件夹名字,例如mkdir myd ...

  2. Unity 4.x Asset Bundle 重名

    在 Unity 4.5.1f3中测试发现如下问题 两个不同文件下相同名字的资源打包成AssetBundle以后加载失败,提示错误  xxxxx can't be loaded because anot ...

  3. 【OSG学习笔记之一:】OSG+VS2010+win7 64位环境搭建

    虽然出生的时候,没有说过“Hello World!”,但是自从走上了编程之路,每一次输出“Hello World!”的时候,都觉得好比中了彩票大奖似的: 仔细算算,从2012年暑假到现在,经历了3年半 ...

  4. Log4j 与 Logback的ConversionPattern对比

    为了能将log4j的配置无缝转到logback,需要了解其中ConversionPattern的差异,以下是对比表格,内容来自: log4j官网 logback官网 其中可能需要转换的地方主要有两块: ...

  5. HTML5中的 Canvas

    什么是Canvas? Canvas元素是HTML5的一部分,允许脚本语言动态渲染位图像.Canvas由一个可绘制地区HTML代码中的属性定义决定高度和宽度.JavaScript代码可以访问该地区,通过 ...

  6. JQuery的开发与使用心得

    关于jQuery的 入门使用jQuery可以很容易或具有挑战性的,这取决于你如何使用JavaScript,HTML,CSS进行开发和编程. 要知道一件重要的事情是,jQuery是只是一个JavaScr ...

  7. [Leetcode]Palindrome Number

    Determine whether an integer is a palindrome. Do this without extra space. 这题貌似解法挺多,直接用简单的把数倒置,没有考虑数 ...

  8. cocos2d-x项目实现android视频播放参考链接

    http://blog.csdn.net/xiaominghimi/article/details/6870259 http://blog.csdn.net/kaitiren/article/deta ...

  9. CUTE-WRV2.1+TCP core(COM5402)的TCP带宽测试

    问题的提出 测试TCP的带宽,硬件平台CUTE-WRV2.1,固件版本WRPCV3.0+COM5402. 代码.工具及实现 1. 在固件中,增加模块,收到TCP数据包后不断地往外发数: library ...

  10. oracle 11g install linux

    #!/bin/bash#Purpose:Create and config oracle install.#Usage:Log on as the superuser('root') #1.creat ...