



全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
题目要求:根据Oracle数据库scott模式下的emp表和dept表,完成下列操作。(1) 查询20号部门的所有员工信息。select * from emp where deptno = 20;(2) 查询所有工种为CLERK的员工的工号、员工名和部门名。select empno,ename,deptno from emp where job like CLERK;(3) 查询奖金(COMM)高于工资(SAL)的员工信息。select * from emp where comm sal;(4) 查询奖金高于工资的20%的员工信息。select * from emp where comm (sal*0.2);(5) 查询10号部门中工种为MANAGER和20号部门中工种为CLERK的员工的信息。select * from emp where (deptno = 10 and job like MANAGER) or (deptno = 20 and job like CLERK);(6) 查询所有工种不是MANAGER和CLERK,且工资大于或等于2000的员工的详细信息。select * from emp where job not in (MANAGER,CLERK) and sal = 2000 ;(7) 查询有奖金的员工的不同工种。select distinct job from emp where comm is not null;(8) 查询所有员工工资和奖金的和。select ename,(sal+nvl(comm,0) salcomm from emp;(9) 查询没有奖金或奖金低于100的员工信息。select * from emp where (comm is null or comm = 10 ;(12) 查询员工信息,要求以首字母大写的方式显示所有员工的姓名。select upper(substr(ename,1,1) | lower(substr(ename,2,length(ename)-1) from emp;(13) 查询员工名正好为6个字符的员工的信息。select * from emp where length(ename)= 6 ;(14) 查询员工名字中不包含字母“S”员工。select * from emp where ename not in (select ename from emp where ename like %S%) ;select * from emp where ename not like %S%;(15) 查询员工姓名的第2个字母为“M”的员工信息。select * from emp where ename like _M%;(16) 查询所有员工姓名的前3个字符。select substr(ename,1,3) from emp ;(17) 查询所有员工的姓名,如果包含字母“s”,则用“S”替换。select replace(ename,s,S) from emp ;(18) 查询员工的姓名和入职日期,并按入职日期从先到后进行排列。select ename,hiredate from emp order by hiredate asc ;(19) 显示所有的姓名、工种、工资和奖金,按工种降序排列,若工种相同则按工资升序排列。select ename,job,sal,comm from emp order by job desc,sal asc ;(20) 显示所有员工的姓名、入职的年份和月份,若入职日期所在的月份排序,若月份相同则按入职的年份排序。select ename,to_char(hiredate,yyyy)|-|to_char(hiredate,mm) from emp order by to_char(hiredate,mm),to_char(hiredate,yyyy);(21) 查询在2月份入职的所有员工信息。select * from emp where to_char(hiredate,mm) = 2 ;(22) 查询所有员工入职以来的工作期限,用“*年*月*日”的形式表示。select ename,floor(sysdate-hiredate)/365)|年|floor(mod(sysdate-hiredate),365)/30)|月|cell(mod(mod(sysdate-hiredate),365),30)|天 from emp ;(23) 查询至少有一个员工的部门信息。select * from dept where deptno in (select distinct deptno from emp where mgr is not null) ;(24) 查询工资比SMITH员工工资高的所有员工信息。select * from emp where sal (select sal from emp where ename like SMITH) ;(25) 查询所有员工的姓名及其直接上级的姓名。select staname,ename supname from (select ename staname,mgr from emp) t join emp on t.mgr=emp.empno ;(26) 查询入职日期早于其直接上级领导的所有员工信息。select * from emp where empno in (select staempno from (select empno staempno,hiredate stahiredate,mgr from emp) t join emp on t.mgr=emp.empno and stahiredate 2500 ;(31) 查询最低工资低于2000的部门及其员工信息。select * from emp where deptno in (select deptno from (select min(sal) min_sal,deptno from emp group by deptno) where min_sal (select avg(sal) from emp) ;(34) 查询与SMITH员工从事相同工作的所有员工信息。select * from emp where job in (select job from emp where ename like SMITH) and ename not like SMITH ;(35) 列出工资等于30号部门中某个员工工资的所有员工的姓名和工资。select ename,sal from emp where sal =any (select sal from emp where deptno = 30) ;(36) 查询工资高于30号部门中工作的所有员工的工资的员工姓名和工资。select ename,sal from emp where sal all (select sal from emp where deptno = 30) ;(37) 查询每个部门中的员工数量、平均工资和平均工作年限。select dname,count,avg_sal,avg_date from dept join (select count(*) count,avg(sal) avg_sal,avg(sysdate-hiredate)/365) avg_date,deptno from emp group by deptno) t on dept.deptno = t.deptno ;(38) 查询从事同一种工作但不属于同一部门的员工信息。select distinct t1.empno,t1.ename,t1.deptno from emp t1 join emp t2 on t1.job like t2.job and t1.deptno t2.deptno ;(39) 查询各个部门的详细信息以及部门人数、部门平均工资。Select dept.*,person_num,avg_sal from dept,(select count(*) person_num,avg(sal) avg_sal,deptno from emp group by deptno) t where dept.deptno = t.deptno ;(40) 查询各种工作的最低工资。select job,min(sal) from emp group by job ;(41) 查询各个部门中的不同工种的最高工资。select max(sal),job,deptno from emp group by deptno,job order by deptno,job ;(42) 查询10号部门员工以及领导的信息。select * from emp where empno in (select mgr from emp where deptno=10) or deptno = 10 ;(43) 查询各个部门的人数及平均工资。select deptno,count(*),avg(sal) from emp group by deptno ;(44) 查询工资为某个部门平均工资的员工信息。select * from emp where sal in (select avg(sal) avg_sal from emp group by deptno) ;(45) 查询工资高于本部门平均工资的员工的信息。select emp.* from emp join (select deptno,avg(sal) avg_sal from emp group by deptno) t on emp.deptno=t.deptno and salavg_sal ;(46) 查询工资高于本部门平均工资的员工的信息及其部门的平均工资。select emp.*,avg_sal from emp join (select deptno,avg(sal) avg_sal from emp group by deptno) t on emp.deptno=t.deptno and salavg_sal ;(47) 查询工资高于20号部门某个员工工资的员工的信息。select * from emp where sal any(select sal from emp where deptno=20);(48) 统计各个工种的人数与平均工资。select job,count(*),avg(sal) from emp group by job ;(49) 统计每个部门中各个工种的人数与平均工资。select deptno,job,count(*),avg(sal) from emp group by deptno,job order by deptno,job;(50) 查询工资、奖金与10 号部门某个员工工资、奖金都相同的员工的信息。select emp.* from emp join (select sal,comm from emp where deptno = 10) t on emp.sal=t.sal and nvl(m,0)=nvl(m,0) and emp.deptno != 10;(51) 查询部门人数大于5的部门的员工的信息。select * from emp where deptno in (select deptno from emp group by deptno having count(*)5);(52) 查询所有员工工资都大于1000的部门的信息。select * from dept where deptno in (select distinct deptno from emp where deptno not in (select distinct deptno from emp where sal 1000) ;(53) 查询所有员工工资都大于1000的部门的信息及其员工信息。select * from emp join dept on dept.deptno in (select distinct deptno from emp where deptno not in (select distinct deptno from emp where sal 1000) and dept.deptno=emp.deptno;(54) 查询所有员工工资都在9003000之间的部门的信息。select * from dept where deptno in (select distinct deptno from emp where deptno not in (select distinct deptno from emp where sal not between 900 and 3000) ;(55) 查询所有工资都在9003000之间的员工所在部门的员工信息。select * from emp where deptno in (select distinct deptno from emp where deptno not in (select distinct deptno from emp where sal not between 900 and 3000) ;(56) 查询每个员工的领导所在部门的信息。select * from (select e1.empno,e1.ename,e1.mgr mno,e2.ename mname,e2.deptno from emp e1 join emp e2 on e1.mgr=e2.empno) t join dept on t.deptno=dept.deptno ;(57) 查询人数最多的部门信息。select * from dept where 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);(58) 查询30号部门中工资排序前3名的员工信息。select * from emp where empno in (select empno from (select empno,sal from emp where deptno=30 order by sal desc) where rownum 4) ;(59) 查询所有员工中工资排在510名之间的员工信息。select * from emp where empno in (select empno from (select empno,rownum num from (select empno,sal from emp order by sal
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年绿色供应链管理在航空航天零部件制造业的应用与推广分析报告
- 2024-2025年太阳能硅片硅碇行业光伏产品市场拓展策略报告
- 第一课 工业革命教学设计-2025-2026学年初中历史与社会(人文地理)八年级下册人教版(新课程标准)
- 2025年电动汽车电池回收利用技术与政策研究评价报告
- 2024年四年级英语下册 Module 4 Things we enjoy Unit 12 The ugly duckling第2课时说课稿 牛津沪教版(三起)
- 第5章 探索技术与工程的世界第2节 像工程师那样实践 教学设计-浙教版七年级上册科学
- 2《找春天》教案-二年级下册语文统编版
- 2025年中国富铬酵母行业市场分析及投资价值评估前景预测报告
- Unit 3 Grammar 说课稿 译林版(2024)七年级英语上册
- 2025年中国风电用巴沙轻木行业市场分析及投资价值评估前景预测报告
- 2025成人高考专升本政治考试模拟试题及答案
- 爱笑的虎鲸课件
- 九章怀沙全文课件
- 损失厌恶效应-洞察及研究
- 2025低空经济发展及关键技术概况报告
- 自闭症中医课件
- 小儿先天性心脏病护理常规
- 2025-2030中国饲用微生态制剂行业发展动态及未来前景展望报告
- 工程围墙销售方案(3篇)
- 危急值报告管理课件
- GB/T 45683-2025产品几何技术规范(GPS)几何公差一般几何规范和一般尺寸规范
评论
0/150
提交评论