




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、-(1)查询20号部门的所有员工信息。select * from emp e where e.deptno=20;-(2)查询奖金(COMM)高于工资(SAL)的员工信息。select * from emp where comm>sal;-(3)查询奖金高于工资的20%的员工信息。select * from emp where comm>sal*0.2;-(4)查询10号部门中工种为MANAGER和20号部门中工种为CLERK的员工的信息。select * from emp e where (e.deptno=10 and e.job='MANAGER') or (
2、e.deptno=20 and e.job='CLERK')-(5)查询所有工种不是MANAGER和CLERK,-且工资大于或等于2000的员工的详细信息。select * from emp where job not in('MANAGER','CLERK') and sal>=2000;-(6)查询有奖金的员工的不同工种。select * from emp where comm is not null;-(7)查询所有员工工资和奖金的和。select (e.sal+nvl(m,0) from emp e;-(8)查询没有奖金或奖金低于1
3、00的员工信息。select * from emp where comm is null or comm<100;-(9)查询员工工龄大于或等于10年的员工信息。select * from emp where (sysdate-hiredate)/365>=10;-(10)查询员工信息,要求以首字母大写的方式显示所有员工的姓名。select initcap(ename) from emp;select upper(substr(ename,1,1)|lower(substr(ename,2) from emp;-(11)显示所有员工的姓名、入职的年份和月份,按入职日期所在的月份排序
4、,-若月份相同则按入职的年份排序。select ename,to_char(hiredate,'yyyy') year,to_char(hiredate,'MM') month from emporder by month,year;-(12)查询在2月份入职的所有员工信息。select * from emp where to_char(hiredate,'MM')='02'-(13)查询所有员工入职以来的工作期限,用“*年*月*日”的形式表示。select e.ename,floor(sysdate-e.hiredate)/36
5、5)|'年'|floor(mod(sysdate-e.hiredate),365)/30)|'月'|floor(mod(mod(sysdate-e.hiredate),365),30)|'日' from emp e;-(14)查询从事同一种工作但不属于同一部门的员工信息。select a.ename,a.job,a.deptno,b.ename,b.job,b.deptno from emp a,emp b where a.job=b.job and a.deptno<>b.deptno; -(15)查询各个部门的详细信息以及部门人数
6、、部门平均工资。select d.deptno,count(e.empno),avg(e.sal),d.dname,d.loc from emp e ,dept dwhere e.deptno=d.deptnogroup by d.deptno,d.dname,d.loc-(16)查询10号部门员工以及领导的信息。select * from emp where empno in(select mgr from emp where deptno=10) or deptno=10;-(17)查询工资为某个部门平均工资的员工信息。select * from empwhere sal in(selec
7、t avg(sal) from emp group by deptno);-(18)查询工资高于本部门平均工资的员工的信息。select * from emp e1 where sal >(select avg(sal) from emp e2 where e2.deptno=e1.deptno);-(19)查询工资高于本部门平均工资的员工的信息及其部门的平均工资。select e.*,a.avgsal from emp e,(select deptno,avg(sal) as avgsal from emp group by deptno) awhere a.deptno=e.dept
8、no and e.sal>a.avgsal;-(20)统计各个工种的人数与平均工资。select count(*),e.job,avg(e.sal) from emp e group by e.job-(21)统计每个部门中各个工种的人数与平均工资。select deptno,job,count(empno),avg(sal) from emp egroup by e.deptno,e.job-(22)查询所有员工工资都大于1000的部门的信息。select * from dept where deptno in(select deptno from empwhere deptno no
9、t in (select distinct deptno from emp where sal<1000);-(23)查询所有员工工资都大于1000的部门的信息及其员工信息。select * from emp e join dept don d.deptnoin (select deptno from empwhere deptno not in (select distinct deptno from emp where sal<1000)and d.deptno=e.deptno;-(24)查询所有员工工资都在9003000之间的部门的信息。select * from dept
10、 where deptno not in(select deptno from emp where sal not between 900 and 3000);-(25)查询所有工资都在9003000之间的员工所在部门的员工信息。select * from emp awhere a.deptno in(select distinct e.deptno from emp e where e.sal between 900 and 3000); -(26)查询每个员工的领导所在部门的信息。select d.* from dept dwhere d.deptno in(select distinct
11、 e2.deptno from emp e1,emp e2where e1.empno=e2.mgr);-(27)查询人数最多的部门信息。select * from deptwhere deptno in(select deptno from (select count(*) count,deptno from emp group by deptno)where count in(select max(count) from (select count(*) count ,deptno from emp group by deptno);-(28)查询30号部门中工资排序前3名的员工信息。se
12、lect * from (select sal from emp where deptno=30 order by sal desc) ewhere rownum<4-(29)查询'JONES'员工及所有其直接、间接下属员工的信息。select e.* from emp estart with ename='JONES'connect by prior empno=mgr;-(30)查询SCOTT员工及其直接、间接上级员工的信息。select e.* from emp estart with ename='SCOTT'connect by
13、prior mgr=empno;-(31)以树状结构查询所有员工与领导之间的层次关系。select substr(sys_connect_by_path(ename,'->'),3),levelfrom empstart with mgr is nullconnect by prior empno=mgr;-(32)向emp表中插入一条记录,员工号为1357,员工名字为oracle,-工资为2050元,部门号为20,入职日期为2002年5月10日。-(33)将各部门员工的工资修改为该员工所在部门平均工资加1000。update emp e set sal=1000+(se
14、lect avg(sal) from emp where deptno=e.deptno);-(34)查询工作等级为2级,1985年以后入职的工作地点为DALLAS的员工编号、-姓名和工资。select e.ename,e.empno,e.sal from emp e,salgrade s,dept dwhere (e.sal between s.losal and s.hisal) and (s.grade=2) and to_char(e.hiredate,'yyyy')>1985and e.deptno=d.deptnoand d.loc='DALLAS
15、39;-35.部门平均薪水最高的部门编号 select * from( select avg(sal) avgsal,deptno from emp group by deptno order by avgsal desc) where rownum=1; select deptno,avg(sal) from emp group by deptno having avg(sal)=( select max(avg(sal) avgsal from emp group by deptno) -36,部门平均薪水最高的部门名称 select d.* from dept d where deptn
16、o in( select deptno from emp group by deptno having avg(sal)=( select max(avg(sal) avgsal from emp group by deptno) -37.平均薪水最低的部门的部门名称 select d.* from dept d where deptno in( select deptno from emp group by deptno having avg(sal)=( select min(avg(sal) avgsal from emp group by deptno)-38.平均薪水等级最低的部门的
17、部门名称select d.dname from dept dwhere d.deptno in (select a.deptno from (select e.deptno from emp e,salgrade s where (e.sal between s.losal and s.hisal)group by e.deptno order by avg(s.grade) awhere rownum=1);-39.部门经理人中,薪水最低的部门名称select dname from dept where deptno=(select deptno from (select deptno fr
18、om emp where job='MANAGER' group by deptnoorder by min(sal) where rownum=1)-40.比普通员工的最高薪水还要高的经理人名称select ename from emp where sal>(select max(sal) from emp where job not in('MANAGER','PRESIDENT') and job='MANAGER' or job='PRESIDENT'-41.删除重复部门,但是留下一项insert into dept values(70,'RESEARCH','DALLAS')select deptno,dname,rowid from deptdelete from dept dwhere rowid<>(select min(rowid) fro
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 基于学科核心素养的议题式教学在高中《哲学与文化》中的应用研究
- 担保人抵押合同示例
- 智能供应链安防系统开发合同
- 树苗买卖合同
- 房屋修建邻里协议书
- 挖机租用合同协议书
- 平安建设共建协议书
- 房租拆改合同协议书
- 平台运营外包协议书
- 放弃失地保险协议书
- 《国家审计准则解读》课件
- 糖尿病患者的药物治疗指导与管理
- 2023医美术后科学修护指南
- 2023年广西物流职业技术学院教师招聘考试笔试题库及答案
- 湖北省天门市2024届中考联考生物试题含解析
- 居民自建桩安装告知书回执
- 广佛环线佛山西站至广州北站段项目输电线路迁改工程环境影响报告表
- 翻译中的文化因素及文化负载词的处理
- 火龙罐技术课件
- 小学英语四年级下册Unit 1 Part B Read and write教学设计2
- 风电场专用箱式变电站技术要求编制说明
评论
0/150
提交评论