查询员工信息:职位与7566员工一样,薪水大于7782员工的薪水 单行
select *
from emp
where job=(select job from emp where empno=7566) and
sal>(select sal from emp where empno=7782)
select *
from emp
where job=(select job from emp where empno=7566) and
sal>(select sal from emp where empno=7782)
2015-07-31
相关子查询,员工sal大于本部门sal
select rownum,empno,ename,sal,(select avg(sal) from emp where deptno=e.deptno ) avgsal
from emp e
where sal>(select avg(sal) from emp where deptno=e.deptno)
select rownum,empno,ename,sal,(select avg(sal) from emp where deptno=e.deptno ) avgsal
from emp e
where sal>(select avg(sal) from emp where deptno=e.deptno)
2015-07-31
分层查询
from emp
connect by prior empno=mgr
start with mgr is null
connect 上一层的员工号=老板号
from emp
connect by prior empno=mgr
start with mgr is null
connect 上一层的员工号=老板号
2015-07-28
分层查询
from emp
connect by prior empno=mgr
connect 上一层的员工号=老板号
from emp
connect by prior empno=mgr
connect 上一层的员工号=老板号
2015-07-28