- 1、本文档共7页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
Oracle经典练习题及标准答案
oracle经典练习sql/*1、选择在部门30中员工的所有信息*/ select * from scott.emp where deptno = 30 /*2、列出职位为(MANAGER)的员工的编号,姓名 */ select empno, ename from scott.emp where job = MANAGER /*3、找出奖金高于工资的员工*/ select * from scott.emp where comm sal /*4、找出每个员工奖金和工资的总和 */ select ename, sal + nvl(comm, 0) from scott.emp /*5、找出部门10中的经理(MANAGER)和部门20中的普通员工(CLERK) */ select * from scott.emp where deptno = 10 and job = MANAGER unionselect * from scott.emp where job = CLERK and deptno = 20 /*6、找出部门10中既不是经理也不是普通员工,而且工资大于等于2000的员工 */ select * from scott.emp where job != MANAGER and job != CLERK and sal 2000 /*7、找出有奖金的员工的不同工作 */ select distinct(job) from scott.emp where comm is not null /*8、找出没有奖金或者奖金低于500的员工*/ select * from scott.emp where comm is not null and comm 500 /*9、显示雇员姓名,根据其服务年限,将最老的雇员排在最前面 */ select ename from scott.emp order by (months_between(sysdate, hiredate) / 12) desc select ename,hiredate from scott.emp order by hiredate /*10、找出每个月倒数第三天受雇的员工*/ select * from scott.emp where hiredate = last_day(hiredate) - 2 /*11、分别用case和decode函数列出员工所在的部门,deptno=10显示部门10, deptno=20显示部门20 deptno=30显示部门30 deptno=40显示部门40 否则为其他部门*/ select ename, case deptno when 10 then 部门10 when 20 then 部门20 when 30 then 部门30 when 40 then 部门40 else 其他部门 end 工资情况from scott.emp select ename, decode(deptno, 10, 部门10, 20, 部门20, 30, 部门30, 40, 部门40, 其他部门) 工资情况from scott.emp /*12、分组统计各部门下工资500的员工的平均工资*/ select avg(sal) from scott.emp where sal 500 group by deptno /*13、统计各部门下平均工资大于500的部门*/ select deptno from scott.emp group by deptno having avg(sal) 500 /*14、算出部门30中得到最多奖金的员工奖金 */ select max(comm) from scott.emp where deptno = 30 /*15、算出部门30中得到最多奖金的员工姓名*/ select ename from scott.emp where deptno = 30 and comm = (select
文档评论(0)