Oracle精选面试题(附答案及分析).doc_第1页
Oracle精选面试题(附答案及分析).doc_第2页
Oracle精选面试题(附答案及分析).doc_第3页
Oracle精选面试题(附答案及分析).doc_第4页
Oracle精选面试题(附答案及分析).doc_第5页
免费预览已结束,剩余1页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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.*, e2.ename from emp e, emp e2 where e.mgr = e2.empno;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 e.deptno = d.deptno and d.dname=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 e.deptno = d.deptno;20. 查询在研发部(RESEARCH)工作员工的编号,姓名,工作部门,工作所在地答案:select empno,ename,dname,loc from emp e, dept d where e.deptno = d.deptno and danme=RESEARCH;21. 查询各个部门的名称和员工人数答案:select * from (select count(*) c, deptno from emp group by deptno) e inner join dept d on e.deptno = d.deptno;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 = e.sal group by sal) 1;24. 查询工资最高的3 名员工信息答案:select * from (select * from emp order by sal desc) where rownum e.sal)+1 rank from emp e order by rank;26. 求入职日期相同的(年月日相同)的员工答案:select * from emp e where (select count(*) from emp where e.hiredate=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. 查询每个员工的信息及工资级别答案:select e.*, sg.grade from emp e, salgrade sg where sal between losal and hisal;30. 查询工资最高的第6-10 名员工答案:select * from ( select e.*,rownum rn from (select * from emp order by sal desc) e where rownum 5;31. 查询各部门工资最高的员工信息答案:select * from emp e where e.sal = (select max(sal) from emp where (deptno = e.deptno);32. 查询每个部门工资最高的前2 名员工答案:select * from emp e where (select count(*) from emp where sal e.sal and e.deptno = deptno) 2;34. 查询所有大于本部门平均工资的员工信息答案:select * from emp e where sal (select avg(sal) from emp where (deptno = e.deptno) order by deptno;35. 查询平均工资最高的部门信息答案:select d.*, avgsal from dept d, (select avg(sal) avgsal, deptno from emp group by deptno) se where avgsal = (select max(avg(sal) from emp group by deptno) and d.deptno = se.deptno;36. 查询大于各部门总工资的平均值的部门信息答案:select d.*,sumsal from dept d, (select sum(sal) sumsal, deptno from emp group by deptno) se where sumsal (select avg(sum(sal) from emp group by deptno) and se.deptno = d.deptno;37. 查询大于各部门总工资的平均值的部门下的员工信息答案:select e.*,sumsal from emp e, (select sum(sal) sumsal, deptno from emp group by deptno) se where sumsal (select avg(sum(sal) from emp group by deptno) and se.deptno = e.deptno;38. 查询没有员工的部门信息答案:select d.* from dept d left join emp e on (e.deptno = d.deptno) where empno is null;39. 查询当前月有多少天答案:select trunc(add_months(sysdate,1),month) - trunc(sysdate,month) from dual;40. 列出最低薪金大于1500的各种工作及此从事此工作的全部雇员人数答案:SELECT job,COUNT(empno)FROM emp GROUP BY job HAVING MIN(sal)1500 ;41. 列出薪金高于公司平均薪金的所有员工,所在部门,上级领导,公司的工资等级答案:SELECT e.empno,e.ename,d.dname,m.ename,s.gradeFROM emp e,dept d,emp m,salgrade sWHERE sal(SELECT AVG(sal) FROM emp) AND e.mgr=m.empno AND d.deptno=e.deptno(+) AND e.sal BETWEEN s.losal AND s.hisal ;42. 列出薪金高于在部门30工作的所有员工的薪金的员工姓名和薪金、部门名称答案:SELECT e.ename,e.sal,d.dname FROM emp e,dept dWHERE sal ALL (SELECT sal FROM emp WHERE deptno=30) AND e.deptno=d.deptno;43. 列出所有部门的详细信息和部门人数答案:SELECT d.dname,d.loc,dt.countFROM dept d,(SELECT deptno,COUNT(*) count FROM emp GROUP BY deptno) dtWHERE d.deptno=dt.deptno ;44. 显示非销售人员工作名称以及从事同一工作雇员的月工资的总和,并且要满足从事同一工作的雇员的月工资合计大于$5000,输出结果按月工资的合计升序排列答案:SELECT job,SUM(sal) sumFROM emp WHERE jobSALESMANGROUP BY job HAVING sum5000 ORDER BY sum ;45. 客户表a(idnameaddress)登陆流水表b(idtime)购物流水表c(idtimeproductidproductnum)1.求每个客户的最新登陆时间time,姓名name,客

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论