欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    2022年sql查询练习题含答案 .pdf

    • 资源ID:34261621       资源大小:50.82KB        全文页数:6页
    • 资源格式: PDF        下载积分:4.3金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要4.3金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    2022年sql查询练习题含答案 .pdf

    -(1)查询 20 号部门的所有员工信息。select * from emp e where e.deptno=20; -(2)查询奖金( COMM )高于工资(SAL)的员工信息。select * from emp where commsal; -(3)查询奖金高于工资的20%的员工信息。select * from emp where commsal*0.2; -(4)查询 10 号部门中工种为MANAGER和 20 号部门中工种为CLERK 的员工的信息。select * from emp e where (e.deptno=10 and e.job=MANAGER) or (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)查询没有奖金或奖金低于100 的员工信息。select * from emp where comm is null or comm=10; -(10) 查询员工信息,要求以首字母大写的方式显示所有员工的姓名。select initcap(ename) from emp; select upper(substr(ename,1,1)|lower(substr(ename,2) from emp; -(11) 显示所有员工的姓名、入职的年份和月份,按入职日期所在的月份排序,-若月份相同则按入职的年份排序。select ename,to_char(hiredate,yyyy) year,to_char(hiredate,MM) month from emp order by month,year; -(12) 查询在 2 月份入职的所有员工信息。select * from emp where to_char(hiredate,MM)=02 -(13) 查询所有员工入职以来的工作期限,用“* 年* 月* 日”的形式表示。select e.ename,floor(sysdate-e.hiredate)/365)|年 |floor(mod(sysdate-e.hiredate),365)/30)| 月 |floor(mod(mod(sysdate-e.hiredate),365),30)| 日 from emp e; -(14) 查询从事同一种工作但不属于同一部门的员工信息。名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 6 页 - - - - - - - - - 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.deptnob.deptno; -(15) 查询各个部门的详细信息以及部门人数、部门平均工资。select d.deptno,count(e.empno),avg(e.sal),d.dname,d.loc from emp e ,dept d where e.deptno=d.deptno group 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 emp where sal in(select 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) a where a.deptno=e.deptno and e.sala.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 e group by e.deptno,e.job -(22) 查询所有员工工资都大于1000 的部门的信息。select * from dept where deptno in (select deptno from emp where deptno not in (select distinct deptno from emp where sal1000); -(23) 查询所有员工工资都大于1000 的部门的信息及其员工信息。select * from emp e join dept d 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 6 页 - - - - - - - - - on d.deptno in (select deptno from emp where deptno not in (select distinct deptno from emp where sal1000) and d.deptno=e.deptno; -(24) 查询所有员工工资都在9003000 之间的部门的信息。select * from dept where deptno not in( select deptno from emp where sal not between 900 and 3000); -(25) 查询所有工资都在9003000 之间的员工所在部门的员工信息。select * from emp a where a.deptno in (select distinct e.deptno from emp e where e.sal between 900 and 3000); -(26) 查询每个员工的领导所在部门的信息。select d.* from dept d where d.deptno in (select distinct e2.deptno from emp e1,emp e2 where e1.empno=e2.mgr); -(27) 查询人数最多的部门信息。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); -(28) 查询 30 号部门中工资排序前3 名的员工信息。select * from (select sal from emp where deptno=30 order by sal desc) e where rownum),3),level from emp start with mgr is null connect by prior empno=mgr; -(32)向 emp 表中插入一条记录,员工号为1357,员工名字为oracle,-工资为 2050 元,部门号为20,入职日期为2002 年 5 月 10 日。-(33)将各部门员工的工资修改为该员工所在部门平均工资加1000。update emp e set sal= 1000+(select 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 d where (e.sal between s.losal and s.hisal) and (s.grade=2) and to_char(e.hiredate,yyyy)1985 and e.deptno=d.deptno and d.loc=DALLAS; -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 deptno in( select deptno from emp group by deptno having avg(sal)=( select max(avg(sal) avgsal from emp group by deptno) -37.平均薪水最低的部门的部门名称名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 6 页 - - - - - - - - - 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.平均薪水等级最低的部门的部门名称select d.dname from dept d where 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) a where rownum=1); -39.部门经理人中,薪水最低的部门名称select dname from dept where deptno= (select deptno from (select deptno from emp where job=MANAGER group by deptno order 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 dept delete from dept d where rowid (select min(rowid) from dept where dname=d.dname and d.loc=loc) -42.更新员工工资为他的主管的工资,奖金update emp e set sal=(select sal from emp where empno=e.mgr), comm=(select comm from emp where empno=e.mgr) update emp e set (sal,comm)=(select sal,comm from emp where empno=e.mgr) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 6 页 - - - - - - - - - rollback; select * from emp; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 6 页,共 6 页 - - - - - - - - -

    注意事项

    本文(2022年sql查询练习题含答案 .pdf)为本站会员(Che****ry)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开