Oracle习题集答案分享
Oracle day10
时间安排:
8:00 — 8:45(测试) 8:55— 9:40(测试)
10:10—10:55(测试讲解)11:05— 11:50 (测试讲解)
测试题:
--1.查询入职日期在2003-1-1到2013-12-31之间的员工信息(to_date ,to_char)
select COUNT(*) from employees --101 推荐使用 where to_char(hire_date,'yyyy-mm-dd') between '2003-01-01' and '2013-12-31';
select COUNT(*) from employees --101
where hire_date between
to_date('2003-01-01','yyyy-mm-dd') and
to_date('2013-12-31','YYYY-MM-DD');
insert into employees
(last_name,email,job_id,hire_date)values('1','1','it',to_date('2013-12-31 12:24:20','yyyy-mm-dd hh24:mi:ss'));
--2. 查询出30号部门工作为IT_PROG的员工信息 where 条件 select * from employees
where department_id = 30
and job_id = 'IT_PROG';
--3. 把入职生日看作是员工生日,求出这个月过生日的员工。 to_char()
select * from employees
where to_char(hire_date,'mm') = to_char(sysdate,'mm')
--4. 查询出名字中含有”L”的员工信息 【模糊查询 like % _】
select * from employees where first_name like '%L%'; --5. 求出2003年各个月入职的员工个数。【to_char group by count 】
select to_char(hire_date,'mm'),count(*) from
employees where to_char(hire_date,'yyyy') = '2003'
group by to_char(hire_date,'mm');
--6. 查询各个部门的平均工资。【group by avg()】
select department_id,avg(salary) from employees group by department_id
--7. 按照入职日期由新到旧的排序员工信息[order by desc
[asc]]
select * from employees
order by hire_date desc;
--*8. 查询员工的信息,附加上其上级的和部门名字(员工信息要求全部显示)。 select * from employees worker left join employees leader
on worker.manager_id = leader.employee_id
left join departments dept on worker.department_id = dept.department_id;
--9. 显示于David相同工资和部门的员工(多列子查询)
select * from employees
where (job_id,department_id)in(select
job_id,department_id from employees where
first_name = 'David')
--10. 查询出工资最高的三名员工信息 (rownum order by) select * from (
select * from employees
where salary is not null
order by salary desc) where rownum <= 3;
--11. 查询出工资最高的6~10名员工信息。
select * from ( select rownum rn ,a.* from ( select * from employees
where salary is not null
order by salary desc)a
where rownum <= 10)
where rn >= 6;
--*12. 查询出没有员工的部门信息。
select * from departments
where department_id not in (
select department_id from employees
where department_id is not null
group by department_id);
--13. 显示部门内最低工资比100部门最低工资要高的部门编号以及部门内最低工资。(group by min())
select department_id,min(salary) from employees group by department_id
having min(salary) > (select min(salary) from
employees where department_id = 100 )
--14. 显示员工的的姓名,工资及工资级别。(非等值连接)
select first_name,salary,grade from employees a ,salgrade b
where a.salary between b.losal and b.hisal; --15. 查询工资与任何一个部门最低工资相等的雇员姓名,工资(子查询 in 多行子查询)
select * from employees where salary in(
select min(salary) from employees
group by department_id);
--*16. 查看所有部门(包含没有员工的部门)的雇员编号、姓名、所在部门编号以及部门名称
select * from departments a
left join employees b
on a.department_id = b.department_id;
--17. 修改数据:所有员工的工资全部上涨10%
update employees set salary = salary * 1.1;
--18.添加一条员工的信息,员工的姓名为(名字:william,工资4000,入职日期)
insert into employees
(first_name,sal,hireDate)values('william',4000,sysdate);
…… 此处隐藏:990字,全部文档内容请下载后查看。喜欢就下载吧 ……
相关推荐:
- [高中教育]电子线路高频非线性部分2.1
- [高中教育]中班美术活动——我的小手
- [高中教育]常用三极管参数大全
- [高中教育]计算机常见故障及解决办法
- [高中教育]风机基础环水平度控制方法探讨
- [高中教育]机械安全工程(专升本)阶段性作业3
- [高中教育]2009年安徽省高考语文考试说明刍议
- [高中教育]unit5 let's eat公开课教案设
- [高中教育]计算机网络原理课后习题答案
- [高中教育]2016-2022年中国新能源市场研究与投资
- [高中教育]2015-2020年中国会议行业市场评估及投
- [高中教育]经销商大会峰会主持人串词开场白
- [高中教育]2014新版北师大数学三年级上册小熊购物
- [高中教育]七年级第一学期体育与健康全套教案
- [高中教育]第三章:国际金融市场
- [高中教育]六年级下册数学单元测试-2.比例 北师大
- [高中教育]2016年上海海事大学法学院624刑法之《
- [高中教育]中国碳化钙产业竞争现状及未来五年投资
- [高中教育]网络时代,我们怎么玩
- [高中教育]圆锥曲线——高中数学基础知识与典型例
- 高集医院世界艾滋病宣传日活动方案
- 苏教版六年级英语上册期末试卷含答案
- 全民枪战生化英雄模式幽灵怎么玩 生化
- 灿烂的宋元文化一导学案
- 第2章货币资金与应收款项
- 北师大版八年级下册数学第三章《分式》
- 浅析高分子材料成型加工技术
- 华南理工大学2013年度共青团先进集体及
- 教师资格科目二小学教案模板(共合集)
- 工程扩建可研报告
- 中华人民共和国海事局2014年度招录公务
- 提高农村小学生作文能力的教学尝试
- 徒手心肺复苏术操作步骤
- 毛概试题库7-15章
- 2014-2015学年度(上)初中班主任工作计
- 企业驾驶员安全生产责任书
- 第07章 不等式测试题-2016年高考文科数
- 医疗器械经营企业工作程序
- 考研英语必背36篇_彩版_精华
- 初中9月13-15假期作业 (1)




