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. JS 获取FileUpload1控件地址

    function openList() { //判断浏览器类型 var isIE = (document.all) ? true : false; ); ); ); var path = " ...

  2. 三种Scriptlet总结

    什么是Scriptlet? 在JSP中,Scriptlet称为脚本小程序,所欲嵌套在HTML代码中的Java程序都必须使用Scriptlet标记出来. 第一种:<% %> 在此Script ...

  3. ASP.NET Core 1.0 部署 HTTPS (.NET Framework 4.5.1)

    var appInsights=window.appInsights||function(config){ function r(config){t[config]=function(){var i= ...

  4. 使用小技巧,让你高效使用Eclipse

    1.自动完成--Eclipse有一个自动完成代码功能,快捷键是ctrl + space.当点击时就会弹出一个对话框,上面有与前后文相关的一些建议.只要有一个可能性,Eclipse就会替你完成. 2.快 ...

  5. Firebird数据库系统的开发团队

    下载Firebird3的发布文档,上面列出了开发团队,仔细看了看,原来俄罗斯人是主导(内核开发),法国人.智利人.巴西人.日本人.荷兰人.捷克人都有.共17人,3人全职. able 13.1. Fir ...

  6. oracle中imp命令详解 .

    转自http://www.cnblogs.com/songdavid/articles/2435439.html oracle中imp命令详解 Oracle的导入实用程序(Import utility ...

  7. usage of elinks (命令行下的firefox)

    No.0 Press "Esc" to show main menu ============================================= No.1 tyep ...

  8. 读Lua游戏开发实践指南

    11月11日开读,到今天正好一个月. 起因是被裁员之后,发现很多公司都在使用lua编写cocos2d-x游戏,原因是上手快,技术人员比较便宜. 如果引擎封装比较好,几乎在lua里写写基本逻辑就行了,不 ...

  9. xpath实例 --//span[contains(.,'资讯管理')]

    实际例子: 实例一: 不得不说下第一个例子,谢谢selenium论坛的大神门,XPATH还有这种方式的定位,传说是“治疗一切跌打损伤,及text找不到”(Antony群友帮解决的,在此谢谢)

  10. Oracle Profile 使用

    一.目的: Oracle系统中的profile可以用来对用户所能使用的数据库资源进行限制,使用Create Profile命令创建一个Profile,用它来实现对数据库资源的限制使用,如果把该prof ...