求部门中哪些人的薪水最高
以下是代码片段: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;
本文就为大家介绍这么多,这只是其中的一小部分,还有很多这里没有介绍到,以后还会继续为大家介绍更多的知识,希望能够帮助到大家
。