Oracle精选面试题(附答案及分析)

  • 格式:doc
  • 大小:27.50 KB
  • 文档页数:6

下载文档原格式

  / 6
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Oracle精选面试题

1.显示10 号部门的所有经理('MANAGER')和20 号部门的所有职员('CLERK')的详细信息

答案:

Select * from emp where deptno=10 and job=’MANAGER’ or deptno=20 and job=’clerk’;

select * from emp where deptno = 10 and job = 'MANAGER' or deptno = 20 and job ='CLERK';

2.显示姓名中没有'L'字的员工的详细信息或含有'SM'字的员工信息

答案:

Select * from emp where ename note like ‘%L%’ or ename like ‘%SM%’;

select * from emp where ename not like '%L%' or ename like '%SM%';

3.显示各个部门经理('MANAGER')的工资

答案:

select deptno,emname, salary from emp_wqq where job='MANAGER';

4.显示佣金(COMM)收入比工资(SAL)高的员工的详细信息

答案:

select * from emp where comm > sal;

5.把hiredate 列看做是员工的生日,求本月过生日的员工

答案:

select * from emp where to_char(hiredate, 'mm') = to_char(sysdate , 'mm');

6.把hiredate 列看做是员工的生日,求下月过生日的员工

答案:

select * from emp where to_char(hiredate, 'mm') = to_char(add_months(sysdate,1) , 'mm');

7.求1982 年入职的员工

答案:

select * from emp where to_char(hiredate,'yyyy') = '1982';

8.求1981 年下半年入职的员工

答案:

select * from emp where hiredate

between to_date('1981-7-1','yyyy-mm-dd') and to_date('1982-1-1','yyyy-mm-dd') - 1;

9.求1981 年各个月入职的的员工个数

答案:

select count(*), to_char(trunc(hiredate,'month'),'yyyy-mm')

from emp where to_char(hiredate,'yyyy')='1981'

group by trunc(hiredate,'month')

order by trunc(hiredate,'month');

10.查询各个部门的平均工资

答案:

select deptno,avg(sal) from emp group by deptno;

11.显示各种职位的最低工资

答案:

select job,min(sal) from emp group by job;

12.按照入职日期由新到旧排列员工信息

答案:

select * from emp order by hiredate desc;

13.查询员工的基本信息,附加其上级的姓名

答案:

select e.*, from emp e, emp e2 where = ;

14.显示工资比'ALLEN'高的所有员工的姓名和工资

答案:

select * from emp where sal > (select sal from emp where ename='ALLEN'); 15.显示与'SCOTT'从事相同工作的员工的详细信息

答案:

select * from emp where job = (select * from emp where ename='SCOTT');

16.显示销售部('SALES')员工的姓名

答案:

select ename from emp e, dept d where = and ='SALES';

17.显示与30 号部门'MARTIN'员工工资相同的员工的姓名和工资

答案:

select ename, sal from emp

where sal = (select sal from emp where deptno=30 and ename='MARTIN');

18.查询所有工资高于平均工资(平均工资包括所有员工)的销售人员('SALESMAN')

答案:

select * from emp where job='SALESMAN' and sal > (select avg(sal) from emp); 19.显示所有职员的姓名及其所在部门的名称和工资

select ename, job, dname from emp e, dept d where = ;

20.查询在研发部('RESEARCH')工作员工的编号,姓名,工作部门,工作所在地

答案:

select empno,ename,dname,loc from emp e, dept d

where = and danme='RESEARCH';

21.查询各个部门的名称和员工人数

答案:

select * from (select count(*) c, deptno from emp group by deptno) e

inner join dept d on = ;

22.查询各个职位员工工资大于平均工资(平均工资包括所有员工)的人数和员工职位

答案:

select job, count(*) from emp where sal > (select avg(sal) from emp) group by job;

23.查询工资相同的员工的工资和姓名

答案:

select * from emp e where (select count(*) from emp where sal = group by sal) > 1;

24.查询工资最高的3 名员工信息

答案:

select * from (select * from emp order by sal desc) where rownum <= 3;

25.按工资进行排名,排名从1 开始,工资相同排名相同(如果两人并列第1 则没有第2 名,从第三名继

续排)

答案:

select e.*, (select count(*) from emp where sal > +1 rank from emp e order by rank;

26.求入职日期相同的(年月日相同)的员工

答案:

select * from emp e where (select count(*) from emp where =hiredate)>1;

27.查询每个部门的最高工资

答案:

select deptno, max(sal) maxsal from emp group by deptno order by deptno;

28.查询每个部门,每种职位的最高工资

答案:

select deptno, job, max(sal) from emp group by deptno, job order by deptno, job;

29.查询每个员工的信息及工资级别