oracle题

--第二题2. 每个班共有多少个学员
select count(c.classname) cnum,c.classname from classes c
inner join students stu on c.classid = stu.classid
group by c.classname
union
select 0 cnum,a.classname from
(select stu.stuname,c.classname from classes c
left join students stu on c.classid = stu.classid
where stu.stuname is null) a
--3. 查询学员的全部信息,包括学生所在班级名称,
--专业名称, 并按学员ID排序
select stu.stuid,stu.stuname,c.classname,m.majorname
from students stu
left join classes c on stu.classid = c.classid
left join major m on stu.majorid = m.majorid
order by stu.stuid
--4. 查询学员姓名中包含‘小’字的学员信息
select * from students where stuname like ‘%女%‘
--5. 查询出生日期在1988年到1990年之间的学员信息
select * from students where birthday
between to_date(‘2000-01-01‘,‘yyyy-mm-dd‘)
and to_date(‘2002-12-30‘,‘yyyy-mm-dd‘)

--7. 查询参加课程’Java程序设计与训练’考试的学员学号和姓名
select stu.stuname,co.courename,sc.score
from course co
inner join stucourse sc
on co.courseid = sc.courseid
inner join students stu on sc.stuid = stu.stuid
AND co.courename = ‘JAVASE‘

select stu.stuname,co.courename,sc.score
from course co
inner join stucourse sc
on co.courseid = sc.courseid AND co.courename = ‘JAVASE‘
inner join students stu on sc.stuid = stu.stuid

select stu.stuname,co.courename,sc.score
from course co
inner join stucourse sc
on co.courseid = sc.courseid
inner join students stu on sc.stuid = stu.stuid
WHERE co.courename = ‘JAVASE‘
--8. 查询未参加某门课程考试的人员名单
select co.courename,sc.score,stu.stuname from course co
left join stucourse sc on co.courseid = sc.courseid
left join students stu on stu.stuid = sc.stuid
where co.courename = ‘ORACLE‘ AND sc.score is null

--9. 查询未参加某门课程考试的人数
select count(co.courename),‘ORACLE‘ COURSENAME from course co
left join stucourse sc on co.courseid = sc.courseid
left join students stu on stu.stuid = sc.stuid
where co.courename = ‘ORACLE‘ AND sc.score is null
--10. 查询所有学员某一门成绩信息

select stu.stuname,co.courename,sc.score
from students stu
left join stucourse sc on stu.stuid = sc.stuid
left join course co on sc.courseid = co.courseid
where co.courename = ‘JAVAEE‘

--12. 查询某班某科学员的总成绩、平均成绩、大于80分的平均成绩
select sum(sc.score) 总成绩,avg(sc.score) 平均成绩,
from students stu
left join stucourse sc on stu.stuid = sc.stuid
left join course co on sc.courseid = co.courseid
left join classes cl on cl.classid = stu.classid
where co.courename = ‘JAVAEE‘
and cl.classname = ‘班级2‘

select avg(sc.score) 大于80分的平均成绩
from students stu
left join stucourse sc on stu.stuid = sc.stuid
left join course co on sc.courseid = co.courseid
left join classes cl on cl.classid = stu.classid
where co.courename = ‘JAVAEE‘
and cl.classname = ‘班级2‘
and sc.score > 80

时间: 2024-11-05 14:58:55

oracle题的相关文章

oracle题库

数据库 --->N实例实例-->表--->字段 数据库中数据都存储在表中表的创建:create table 表名( 字段名 数据类型, 字段2 数据类型) 注意:1.sql语法不区分大小写,数据区分大小写2.表名的命名规则 字母,数字,下划线,-,$,# 3.字段命名也一样oooo 数据类型--字符串类型char(长度) 最大2000字节,如果数据没有达到声明字节的长度,剩余的空间以空格来替补.长度指的是字节大小,例如一个中文在GBK编码中占据两个字节,UTF-8编码中占据3个字节 va

Oracle OCP 11G 051(61题版本)答案解析目录

Oracle OCP 11G 051(61题版本)答案解析目录 61题版本 V9.02 1 http://blog.csdn.net/rlhua/article/details/17635843 2  http://blog.csdn.net/rlhua/article/details/17635887 3 http://blog.csdn.net/rlhua/article/details/17635919 86 4 http://blog.csdn.net/rlhua/article/det

公司考核题-(ORACLE篇二)

本篇主要考察的是算法--递归编程(树形的生成)--->本篇中的代码也可以使用ORACLE中的"CONNECT BY"来完成要求. 考核题目如下: 程序如下: 1.创建表deptframwork insert into deptframwork (DEPTID, UPPERID, DEPTNAME, DEPTNUM, CREATETIME, WHOLENAME, EMPLOYEE) values (1, 0, '省公司电力本部', 1001, to_date('03-02-2010

Oracle DBA面试突击题

一份ORACLE DBA面试题 一:SQL tuning 类 1:列举几种表连接方式 答:Oracle的多表连接算法有Nest Loop.Sort Merge和Hash Join三大类,每一类又可以分为三小类. 以Nest Loop为例: 传统的Nest Loop连接: 针对In.Exists优化的Semi Nest Loop: 专门针对Not In.Not Exists优化的Anti Nest Loop. Semi/Anti *** Join这几种也叫半连接. (可以补充一下这三个连接的不同之

Oracle 051 的几个题 (oracle 11g)

1.    INTERVAL的用法 SELECT INTERVAL '300' MONTH,INTERVAL '54-2' YEAR TO MONTH,INTERVAL '11:12:10.1234567' HOUR TO SECOND FROM dual; 查询结果为: INTERVAL'300'MONTH --------------------------------------------------------------------------- INTERVAL'54-2'YEAR

oracle 上机操作题整理

每个题目都包含了一些知识点,认真做题慢慢领悟吧! 查找出当前用户模式下,每张表的记录数,以scott用户为例,结果应如下: DEPT...................................4 EMP...................................14 BONUS.................................0 SALGRADE.............................5 declare type tab_name is ta

Oracle错题集

1.oracle 中 date类型的在数据库怎么存入 链接:https://www.cnblogs.com/bdqnhhm/p/6683458.html 2.Oracle数据库以date类型保存日期时,Java中用哪个类对应数据库的date类型?(转载) 链接:https://www.cnblogs.com/bdqnhhm/p/6683458.html 3.JDBC连接Oracle数据库后实现对emp 表数据的增删改查(转载) https://blog.csdn.net/qq_38056704/

【Oracle 12c】CUUG OCP认证071考试原题解析(30)

30.choose the best answer Examine the commands used to create DEPARTMENT_DETAILS and COURSE_DETAILS: SQL> CREATE TABLE DEPARTMENT_DETAILS (DEPARTMENT_ID NUMBER PRIMARY KEY, DEPARTMENT_NAME VARCHAR2(50) , HOD VARCHAR2(50)); SQL> CREATE TABLE COURSE_D

【ocp-12c】最新Oracle OCP-071考试题库(39题)

39.choose the best answer View the Exhibit and examine the description of the EMPLOYEES table. You want to calculate the total remuneration for each employee. Total remuneration is the sum of the annual salary and the percentage commission earned for