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. <数据结构与算法>之字符串,散列,布隆过滤器。

    1:字符串 字符串是一组由数字,字符,下划线的一串字符,是特殊的一维数组. 2:字符串的应用 字符串移位包含问题: 例:给定两个字符串s1和s2,要求判断s2是否能被s1做循环移位得到字符串包含.例如 ...

  2. js生成验证码并检验

    <html> <head> <title>验证码</title> <style type="text/css"> #co ...

  3. 一个好用的C#类型转换器

    public static object ChangeType(object value, Type targetType) { if (targetType.IsGenericType && ...

  4. HttpServletRequest的Attribute和Parameter区别

    HttpServletRequest类既有getAttribute()方法,也由getParameter()方法,这两个方法有以下的组件通过getParameter()方法来获得请求参数,例如假定we ...

  5. vb- ----之常用函数

    [VB]常用函数 2007-10-25 10:52 3375人阅读 评论(1) 收藏 举报 vbstringdateintegervbscriptwindows (一)类型转换类函数1. CType( ...

  6. CAS 4.0.0RC 配置MD5验证功能

    配置内容同一样,只是增加一些配置. 因为cas已经默认就支持MD5加密验证,所以只是修改一下配置就可以了. <bean id="primaryAuthenticationHandler ...

  7. CAS 4.0.0RC 配置通过数据库认证用户登录

    配置通过数据库认证用户登录 打开webapp\WEB-INF目录下的deployerConfigContext.xml,替换 <bean id="primaryAuthenticati ...

  8. 【C-分支结构】

    一.关系运算符 双目运算符 自左向右结合 关系运算符的优先级低于算术运算符,高于赋值运算符 <(小于) <=(小于或等于) >(大于) >=(大于或等于) ==(等于) !=( ...

  9. Replication的犄角旮旯(一)--变更订阅端表名的应用场景

    <Replication的犄角旮旯>系列导读 Replication的犄角旮旯(一)--变更订阅端表名的应用场景 Replication的犄角旮旯(二)--寻找订阅端丢失的记录 Repli ...

  10. 蛙蛙推荐:快速自定义Boostrap样式

    现在越来越多的网站使用Bootstrap,相信大家也审美疲劳了,所以我们要用Bootstrap的第一步就是先把顶部的导航栏来自定义一下. 我现在使用的是bootstrap3.0,顶部导航定义如下 &l ...