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

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

26、  查询存在有85分以上成绩的课程Cno.

select s.cno from SCORE s where s.degree>85

27、查询出“计算机系“教师所教课程的成绩表。

28、查询“计算机系”与“电子工程系“不同职称的教师的Tname和Prof。

select tname,prof from teacher where prof not in

(

select a.prof from

(select prof from teacher where depart='电子工程系') a

join

(select prof from teacher where depart ='计算机系') b

on a.prof =b.prof ) and depart in ('计算机系','电子工程系')

29、查询选修编号为“3-105“课程且成绩至少高于选修编号为“3-245”的同学的Cno、Sno和Degree,并按Degree从高到低次序排序。

select t.degree from SCORE t where t.cno='3-105' and t.degree>(select min(t.degree) from SCORE t where t.cno='3-245')

30、查询选修编号为“3-105”且成绩高于选修编号为“3-245”课程的同学的Cno、Sno和Degree.

select t.degree from SCORE t where t.cno='3-105' and t.degree> any (select t.degree from SCORE t where t.cno='3-245') order by t.degree desc;

31、 查询所有教师和同学的name、sex和birthday.

select tname,tsex,t.tbirthday from teacher t '

union

select sname,ssex,s.sbirthday from student s ';

32、查询所有“女”教师和“女”同学的name、sex和birthday.

select tname,tsex,t.tbirthday from teacher t where t.tsex='女'

union

select sname,ssex,s.sbirthday from student s where s.ssex='女';

33、 查询成绩比该课程平均成绩低的同学的成绩表。

34、 查询所有任课教师的Tname和Depart.

select tname,depart from teacher t where t.tno  in

(select tno from course c where c.cno in(select cno from score))

35 、 查询所有未讲课的教师的Tname和Depart.

select tname,depart from teacher t where t.tno not in

(select tno from course c where c.cno in(select cno from score))

36、查询至少有2名男生的班号。

37、查询Student表中不姓“王”的同学记录。

38、查询Student表中每个学生的姓名和年龄。

38 select s.sname,to_char(sysdate,'yyyy')-to_char(s.sbirthday,'yyyy') from student s where s.sbirthday is not null

39、查询Student表中最大和最小的Sbirthday日期值。

39 select max(to_char(s.sbirthday,'mm/dd')),min(to_char(s.sbirthday,'mm/dd')) from student s

40、以班号和年龄从大到小的顺序查询Student表中的全部记录。

40 select s.* from student s where s.sbirthday is not null order by s.class,to_char(sysdate,'yyyy')

41、查询“男”教师及其所上的课程。

41 select c.tno,c.cno from course c inner join teacher t on t.tno=c.tno where t.tsex='男'

42、查询最高分同学的Sno、Cno和Degree列。

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

43、查询和“李军”同性别的所有同学的Sname.

43 select s.sname from student s where s.ssex in (select ssex from student where ssex='男')

44、查询和“李军”同性别并同班的同学Sname.

44 select s.sname from student s where s.ssex in (select ssex from student where ssex='男') and s.class in
(select class from student where sname='李军')

45、查询所有选修“计算机导论”课程的“男”同学的成绩表。

45 select s.* from score s inner join course c on c.cno=s.cno inner join student ss on ss.sno=s.sno
where ss.ssex='男' and c.cname='计算机导论'

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

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

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

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

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

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

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

  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. 健忘vs总结

    上周入职新公司,报道之前自己也曾想过要从头开始,用一个新的精神面貌来迎接新的起点,培养一些新的习惯. 周四是15日,新公司的发薪日(当然还没有我的份~),小组群内一个刚毕业的新人兴冲冲的说终于领到第一 ...

  2. BZOJ1742[Usaco2005 nov]Grazing on the Run

    Description John养了一只叫Joseph的奶牛.一次她去放牛,来到一个非常长的一片地,上面有N块地方长了茂盛的草.我们可 以认为草地是一个数轴上的一些点.Joseph看到这些草非常兴奋, ...

  3. html 页面内锚点定位及跳转方法总结

    第一种方法,也是最简单的方法是锚点用<a>标签,在href属性中写入DIV的id.如下: <!DOCTYPE html><html><head> < ...

  4. Java日志系统及框架分析

    最近在考虑将容器(Tomcat)内的应用日志统一成slf4j + logback,主要目的有: 快速定位应用日志输出路径,方便日志的采集: 能动态调整日志的级别,方便线上问题定位: 方便在容器层面做扩 ...

  5. Windows Phone 8.1 新特性 - 控件之列表选择控件

    本篇我们来介绍Windows Phone 8.1 新特性中的列表选择控件. 在Windows Phone 8 时代,大家都会使用 LongListSelector 来实现列表选择控件,对数据进行分组显 ...

  6. 数据库中用varbinary存储二进制数据

    问题描述:将图片.二进制文件内容等数据存储在数据库中,并能从数据库中取出还原为图片或文件,数据库存储二进制数据用varbinary字段. 分析:由于之前数据库中没有用过varbinary存储数据,首先 ...

  7. DFS security warning and use group policy to set up internet security zones

    Opening a file from a DFS domain share shows a security warning while openning from the server share ...

  8. Entity Framework EF6使用 MySql创建数据库异常解决办法

    EF6使用MySQL数据库时,第一次创建数据库出现“Specified key was too long; max key length is 767 bytes”错误,解决办法请见以下连接. htt ...

  9. 自己做了一个json格式化工具,亲测可以使用

    随笔背景:在向后台请求数据之后,我们常常会拿到一串json格式.此时,为了方便查看key-value,程序猿们常常使用一些在线json格式化工具或者是类似于notepadd++这样的工具进行转换.今天 ...

  10. 利用html5 canvas实现纯前端上传图片的裁剪

    今天跟大家分享一个前端裁剪图片的方法.许多网站都有设置用户头像的功能,用户可以选择一张本地的图片,然后用网站的裁剪工具进行裁剪,然后设置大小,位置合适的头像.当然,网上也有一些用js写的诸如此类裁剪的 ...