1818IP-服务器技术教程,云服务器评测推荐,服务器系统排错处理,环境搭建,攻击防护等

当前位置:首页 - 数据库 - 正文

君子好学,自强不息!

Oracle操作常见的代码分析

2022-11-18 | 数据库 | 1818ip | 579°c
A+ A-

求部门中哪些人的薪水***

以下是代码片段:select ename,sal from emp join (select max(sal) max_sal, deptno from emp group by deptno) t on (emp.sal = t.max_sal and emp.deptno = t.deptno); –

求部门平均薪水的等级

以下是代码片段:select deptno,avg_sal,grade from (select deptno,avg(sal) avg_sal from emp group by deptno) t join salgrade s on (t.avg_sal between s.losal and s.hisal);

求部门平均的薪水等级

以下是代码片段:select deptno,avg(grade) from (select deptno,ename,grade from emp join salgrade s on (emp.sal between s.losal and s.hisal)) t group by deptno;

雇员中哪些人是经理人

以下是代码片段:select ename from emp where empno in (select distinct mgr from emp);

不用组函数,求薪水的***值

以下是代码片段:select sal from emp where sal not in (select distinct e1.sal from emp e1 join emp e2 on (e1.sal < e2.sal))

用组函数,求薪水的***值

以下是代码片段: select max(sal) from emp;

求平均薪水***的部门的部门编号

以下是代码片段:select deptno , avg_sal from (select avg(sal) avg_sal,deptno from emp group by deptno) t where avg_sal = (select max(avg_sal) from (select avg(sal) avg_sal,deptno from emp group by deptno) t);

组函数嵌套的写法

以下是代码片段:select deptno , avg_sal from (select avg(sal) avg_sal,deptno from emp group by deptno) t where avg_sal = (select max(avg(sal)) from emp group by deptno);

求平均薪水***的部门的名称

以下是代码片段:select dname from dept where deptno = ( select deptno from (select avg(sal) avg_sal,deptno from emp group by deptno) t where avg_sal = (select max(avg_sal) from (select avg(sal) avg_sal,deptno from emp group by deptno) t) );

求平均薪水的等级***的部门的部门名称

以下是代码片段:select avg(sal) avg_sal,deptno from emp group by deptno

部门平均薪水

以下是代码片段:select min(avg_sal) from ( select avg(sal) avg_sal,deptno from emp group by deptno )

平均工资的最小值

以下是代码片段:select avg_sal,deptno from (select avg(sal) avg_sal,deptno from emp group by deptno) t where avg_sal = ( select min(avg_sal) from ( select avg(sal) avg_sal,deptno from emp group by deptno ) )

平均工资的最小值及部门编号

以下是代码片段:select t.avg_sal,t.deptno,s.grade from (select avg(sal) avg_sal,deptno from emp group by deptno) t join salgrade s on (t.avg_sal between s.losal and s.hisal) where avg_sal = ( select min(avg_sal) from ( select avg(sal) avg_sal,deptno from emp group by deptno ) )

平均工资的最小值及部门编号和工资等级

以下是代码片段:select d.dname,t.avg_sal,t.deptno,s.grade from (select avg(sal) avg_sal,deptno from emp group by deptno) t join salgrade s on (t.avg_sal between s.losal and s.hisal) join dept d on (t.deptno = d.deptno) where avg_sal = ( select min(avg_sal) from ( select avg(sal) avg_sal,deptno from emp group by deptno ) )

平均工资的最小值及部门编号和工资等级及部门名称

Another 按照题意的写法

以下是代码片段:select t1.deptno,t1.avg_sal,grade,d.dname from ( select deptno,avg_sal,grade from (select deptno,avg(sal) avg_sal from emp group by deptno) t join salgrade s on (t.avg_sal between s.losal and s.hisal) ) t1 join dept d on (t1.deptno = d.deptno) where grade = ( select min(grade) from ( select deptno,avg_sal,grade from (select deptno,avg(sal) avg_sal from emp group by deptno) t join salgrade s on (t.avg_sal between s.losal and s.hisal) ) );

创建视图或者表,如果没有权限

以下是代码片段:conn sys/sys as sysdba;

已连接。

以下是代码片段:grant create table, create view to scott;

本文就为大家介绍这么多,这只是其中的一小部分,还有很多这里没有介绍到,以后还会继续为大家介绍更多的知识,希望能够帮助到大家。

本文来源:1818IP

本文地址:https://www.1818ip.com/post/4501.html

免责声明:本文由用户上传,如有侵权请联系删除!

发表评论

必填

选填

选填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。