Eg:要求查询出每一个雇员的编号,姓名,工资,领导的姓名,部门名称及位置,工资所在公司的工资等级
SQL> select e.ename,e.empno,e.sal,m.ename,d.loc,d.dname,s.grade
from emp e,emp m,dept d,salgrade s
where e.deptno=d.deptno(+) and e.mgr=m.empno(+) and e.sal between s.losal and s.hisal;
2 3
ENAME EMPNO SAL ENAME LOC DNAME
GRADE
SMITH 7369 800 FORD DALLAS RESEARCH
1
JAMES 7900 950 BLAKE CHICAGO SALES
1
ADAMS 7876 1100 SCOTT DALLAS RESEARCH
1
ENAME EMPNO SAL ENAME LOC DNAME
GRADE
WARD 7521 1250 BLAKE CHICAGO SALES
2
MARTIN 7654 1250 BLAKE CHICAGO SALES
2
MILLER 7934 1300 CLARK NEW YORK ACCOUNTING
2
ENAME EMPNO SAL ENAME LOC DNAME
GRADE
TURNER 7844 1500 BLAKE CHICAGO SALES
3
ALLEN 7499 1600 BLAKE CHICAGO SALES
3
CLARK 7782 2450 KING NEW YORK ACCOUNTING
4
ENAME EMPNO SAL ENAME LOC DNAME
GRADE
BLAKE 7698 2850 KING CHICAGO SALES
4
JONES 7566 2975 KING DALLAS RESEARCH
4
SCOTT 7788 3000 JONES DALLAS RESEARCH
4
ENAME EMPNO SAL ENAME LOC DNAME
GRADE
FORD 7902 3000 JONES DALLAS RESEARCH
4
KING 7839 5000 NEW YORK ACCOUNTING
5