20_学生选课数据库SQL语句练习题1
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的更多相关文章
- 20_学生选课数据库SQL语句练习题
一. 设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四个表的结构分别如表1-1的表(一)~表( ...
- 学生选课数据库SQL语句练习题
一. 设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四个表的结构分别如表1-1的表(一)~表( ...
- _学生选课数据库SQL语句练习题
1. 查询Student表中的所有记录的Sname.Ssex和Class列. select Sname,Ssex,t.sclass from STUDENT t 2. 查询教师所有的单位即不重复的De ...
- (10.09作业)学生选课数据库SQL语句练习题
- 学生选课数据库SQL语句45道练习题整理及mysql常用函数(20161019)
学生选课数据库SQL语句45道练习题: 一. 设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四 ...
- SQL Server T—SQL 学生选课数据库SQL语句考试题(45道题)
题目 设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四个表的结构分别如表1-1的表(一)~表(四)所示,数据如表1 ...
- 选课数据库SQL语句练习题
表(一)Student (学生表) 属性名 数据类型 可否为空 含 义 Sno varchar (20) 否 学号(主码) Sname varchar (20) 否 学生姓名 Ssex varchar ...
- 学生选课数据库MySQL语句练习题45道
1. 查询Student表中的所有记录的Sname.Ssex和Class列. select Sname,Ssex,Class from Student;2. 查询教师所有的单位即不重复的Depart列 ...
- 数据库SQL语句练习题
一. 设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四个表的结构分别如表1-1的表(一)~表( ...
随机推荐
- PHP 通过设置P3P头来实现跨域访问COOKIE
CentOS的系统(Linux 内核) 编辑HOST vi /etc/hosts 加入127.0.0.1 www.a.com127.0.0.1 www.b.com 首先:创建 a_setcookie. ...
- HDU 4336 Card Collector (期望DP+状态压缩 或者 状态压缩+容斥)
题意:有N(1<=N<=20)张卡片,每包中含有这些卡片的概率,每包至多一张卡片,可能没有卡片.求需要买多少包才能拿到所以的N张卡片,求次数的期望. 析:期望DP,是很容易看出来的,然后由 ...
- IOS学习笔记 O2
第二章 Objective-C语言基础进阶 一.Objective-C语言写法简化 利用@property快速生成setget方法 1.首先来复习一下setget写法,这是上一节笔记写的setget方 ...
- IE 浏览器 如何关闭令人讨厌的“此网站需要运行以下加载项:XXX。如果您信任该网站和该加载项并允许运行该加载项,请单击这里...
1.运行gpedit.msc 2.在打开的组策略中打开用户配置——管理模板——Windows组件——Internet Explorer 3.选择“关闭ActiveX选择启用提示”,将其状态改为“已启用 ...
- Firebird数据库的Select语句
select first 10 skip 8 * from t_data //跳过前8行不要,取10行,即取第9行到18行共10行 select first 10 * from t_data ...
- wince mobile环境下播放WAV声音
[DllImport("coredll", EntryPoint = "PlaySound")] public static extern i ...
- arduino 入手
新买了个ardhuino 入门套件 1. Win7 Driver issue: Need to install the below drivers, because my windows is ins ...
- 好玩儿的Game
1. 种类: 威佐夫游戏, Bash游戏, Nim游戏, 等. 2. 理论: 胜态一定可以通过某种策略走向必败态; 而必败态采取任何策略都将走向胜态. 用图论的话来说, 因为必败态只能走向胜态, 所以 ...
- java基础3_流程控制语句
一 条件判断 1. 条件运算符(三元表达式) ,其形式为: type d = a ? b : c; 具体化形式为:int d = 2 < 1 ? 3 : 4; 2. 轻量级的文本编辑器:Ultr ...
- Word文字处理器发展演变
随着信息技术的不断发展,以前书面化的信笺,笔记,书籍以及作业演变成现在不断更新的电子化Word文档. Word是目前世界上最流行.最常用的文字编辑,排版软件,使用它不仅可以提高文档的编辑效率,在修改时 ...