You are on page 1of 18

SQL> cl scr SQL> 2 3 4 SELECT E.Ename, D.Deptno, D.Dname FROM Emp E, Dept D WHERE E.Deptno = D.Deptno ORDER BY E.

Deptno;

ENAME DEPTNO DNAME ---------- ---------- -------------KING 10 ACCOUNTING CLARK 10 ACCOUNTING MILLER 10 ACCOUNTING JONES 20 RESEARCH SCOTT 20 RESEARCH ADAMS 20 RESEARCH SMITH 20 RESEARCH FORD 20 RESEARCH BLAKE 30 SALES MARTIN 30 SALES ALLEN 30 SALES ENAME DEPTNO DNAME ---------- ---------- -------------TURNER 30 SALES JAMES 30 SALES WARD 30 SALES 14 rows selected. SQL> ed Wrote file afiedt.buf 1 2 3 4* SQL> SELECT E.Ename, D.Deptno, D.Dname FROM Emp E, Dept D WHERE E.Deptno(+) = D.Deptno ORDER BY E.Deptno /

ENAME DEPTNO DNAME ---------- ---------- -------------KING 10 ACCOUNTING CLARK 10 ACCOUNTING MILLER 10 ACCOUNTING JONES 20 RESEARCH SCOTT 20 RESEARCH ADAMS 20 RESEARCH SMITH 20 RESEARCH FORD 20 RESEARCH BLAKE 30 SALES MARTIN 30 SALES ALLEN 30 SALES ENAME DEPTNO DNAME ---------- ---------- -------------TURNER 30 SALES JAMES 30 SALES WARD 30 SALES 40 OPERATIONS 15 rows selected.

SQL> ed Wrote file afiedt.buf 1 2 3 4* SQL> SELECT E.Ename, D.Deptno, D.Dname FROM Emp E, Dept D WHERE E.Deptno = D.Deptno(+) ORDER BY E.Deptno /

ENAME DEPTNO DNAME ---------- ---------- -------------MILLER 10 ACCOUNTING CLARK 10 ACCOUNTING KING 10 ACCOUNTING ADAMS 20 RESEARCH SCOTT 20 RESEARCH SMITH 20 RESEARCH FORD 20 RESEARCH JONES 20 RESEARCH WARD 30 SALES JAMES 30 SALES TURNER 30 SALES ENAME DEPTNO DNAME ---------- ---------- -------------ALLEN 30 SALES MARTIN 30 SALES BLAKE 30 SALES 14 rows selected. SQL> INSERT INTO Dept 2 VALUES(50, 'SHIPPING', 'CHENNAI'); 1 row created. SQL> INSERT INTO Dept 2 VALUES(60, 'CARGO', 'MUMBAI'); 1 row created. SQL> INSERT INTO Dept 2 VALUES(70, 'COURIER', 'DELHI'); 1 row created. SQL> cl scr SQL> 2 3 4 SELECT E.Ename, D.Deptno, D.Dname FROM Emp E, Dept D WHERE E.Deptno (+) = D.Deptno ORDER BY E.Deptno;

ENAME DEPTNO DNAME ---------- ---------- -------------KING 10 ACCOUNTING CLARK 10 ACCOUNTING MILLER 10 ACCOUNTING JONES 20 RESEARCH

SCOTT ADAMS SMITH FORD BLAKE MARTIN ALLEN

20 20 20 20 30 30 30

RESEARCH RESEARCH RESEARCH RESEARCH SALES SALES SALES

ENAME DEPTNO DNAME ---------- ---------- -------------TURNER 30 SALES JAMES 30 SALES WARD 30 SALES 50 SHIPPING 60 CARGO 70 COURIER 40 OPERATIONS 18 rows selected. SQL> ed Wrote file afiedt.buf 1 2 3 4 5 6 7 8 9* SQL> SELECT E.Ename, E.Job, D.Deptno, D.Dname, D.Loc FROM Emp E, Dept D WHERE E.Deptno (+) = D.Deptno ORDER BY E.Deptno / JOB DEPTNO DNAME --------- ---------- -------------PRESIDENT 10 ACCOUNTING MANAGER 10 ACCOUNTING CLERK 10 ACCOUNTING MANAGER 20 RESEARCH ANALYST 20 RESEARCH CLERK 20 RESEARCH CLERK 20 RESEARCH ANALYST 20 RESEARCH MANAGER 30 SALES SALESMAN 30 SALES SALESMAN 30 SALES JOB DEPTNO DNAME --------- ---------- -------------SALESMAN 30 SALES CLERK 30 SALES SALESMAN 30 SALES 50 SHIPPING 60 CARGO 70 COURIER 40 OPERATIONS LOC ------------NEW YORK NEW YORK NEW YORK DALLAS DALLAS DALLAS DALLAS DALLAS CHICAGO CHICAGO CHICAGO LOC ------------CHICAGO CHICAGO CHICAGO CHENNAI MUMBAI DELHI BOSTON

ENAME ---------KING CLARK MILLER JONES SCOTT ADAMS SMITH FORD BLAKE MARTIN ALLEN ENAME ---------TURNER JAMES WARD

18 rows selected.

SQL> ed Wrote file afiedt.buf 1 2 3 4 5 6 7 8 9* SQL> SELECT E.Ename, E.Job, E.Deptno, D.Dname, D.Loc FROM Emp E, Dept D WHERE E.Deptno (+) = D.Deptno ORDER BY E.Deptno / JOB DEPTNO DNAME --------- ---------- -------------PRESIDENT 10 ACCOUNTING MANAGER 10 ACCOUNTING CLERK 10 ACCOUNTING MANAGER 20 RESEARCH ANALYST 20 RESEARCH CLERK 20 RESEARCH CLERK 20 RESEARCH ANALYST 20 RESEARCH MANAGER 30 SALES SALESMAN 30 SALES SALESMAN 30 SALES JOB DEPTNO DNAME --------- ---------- -------------SALESMAN 30 SALES CLERK 30 SALES SALESMAN 30 SALES SHIPPING CARGO COURIER OPERATIONS LOC ------------NEW YORK NEW YORK NEW YORK DALLAS DALLAS DALLAS DALLAS DALLAS CHICAGO CHICAGO CHICAGO LOC ------------CHICAGO CHICAGO CHICAGO CHENNAI MUMBAI DELHI BOSTON

ENAME ---------KING CLARK MILLER JONES SCOTT ADAMS SMITH FORD BLAKE MARTIN ALLEN ENAME ---------TURNER JAMES WARD

18 rows selected. SQL> ed Wrote file afiedt.buf 1 2 3 4 5 6 7 8 9* SQL> SELECT NVL(E.Ename, 'Not Recruited') Ename, NVL(E.Job, 'Not Available') Job, E.Deptno, D.Dname, D.Loc FROM Emp E, Dept D WHERE E.Deptno (+) = D.Deptno ORDER BY E.Deptno / JOB DEPTNO DNAME ------------- ---------- -------------PRESIDENT 10 ACCOUNTING MANAGER 10 ACCOUNTING CLERK 10 ACCOUNTING MANAGER 20 RESEARCH LOC ------------NEW YORK NEW YORK NEW YORK DALLAS

ENAME ------------KING CLARK MILLER JONES

SCOTT ADAMS SMITH FORD BLAKE MARTIN ALLEN ENAME ------------TURNER JAMES WARD Not Recruited Not Recruited Not Recruited Not Recruited

ANALYST CLERK CLERK ANALYST MANAGER SALESMAN SALESMAN

20 20 20 20 30 30 30

RESEARCH RESEARCH RESEARCH RESEARCH SALES SALES SALES

DALLAS DALLAS DALLAS DALLAS CHICAGO CHICAGO CHICAGO LOC ------------CHICAGO CHICAGO CHICAGO CHENNAI MUMBAI DELHI BOSTON

JOB DEPTNO DNAME ------------- ---------- -------------SALESMAN 30 SALES CLERK 30 SALES SALESMAN 30 SALES Not Available SHIPPING Not Available CARGO Not Available COURIER Not Available OPERATIONS

18 rows selected. SQL> ed Wrote file afiedt.buf 1 2 3 4 5 6 7 8 9* SQL> SELECT NVL(E.Ename, 'Not Recruited') Ename, NVL(E.Job, 'Not Available') Job, D.Deptno, D.Dname, D.Loc FROM Emp E, Dept D WHERE E.Deptno (+) = D.Deptno ORDER BY E.Deptno / JOB DEPTNO DNAME ------------- ---------- -------------PRESIDENT 10 ACCOUNTING MANAGER 10 ACCOUNTING CLERK 10 ACCOUNTING MANAGER 20 RESEARCH ANALYST 20 RESEARCH CLERK 20 RESEARCH CLERK 20 RESEARCH ANALYST 20 RESEARCH MANAGER 30 SALES SALESMAN 30 SALES SALESMAN 30 SALES JOB DEPTNO DNAME ------------- ---------- -------------SALESMAN 30 SALES CLERK 30 SALES SALESMAN 30 SALES Not Available 50 SHIPPING Not Available 60 CARGO Not Available 70 COURIER Not Available 40 OPERATIONS LOC ------------NEW YORK NEW YORK NEW YORK DALLAS DALLAS DALLAS DALLAS DALLAS CHICAGO CHICAGO CHICAGO LOC ------------CHICAGO CHICAGO CHICAGO CHENNAI MUMBAI DELHI BOSTON

ENAME ------------KING CLARK MILLER JONES SCOTT ADAMS SMITH FORD BLAKE MARTIN ALLEN ENAME ------------TURNER JAMES WARD Not Recruited Not Recruited Not Recruited Not Recruited

18 rows selected.

SQL> 2 3 4 5 6

SELECT E.Ename, D.Deptno, D.Dname, D.Loc FROM Emp E, Dept D WHERE E.Deptno(+) = D.Deptno AND E.Deptno = 10 ORDER BY E.Deptno; LOC ------------NEW YORK NEW YORK NEW YORK

ENAME DEPTNO DNAME ---------- ---------- -------------KING 10 ACCOUNTING CLARK 10 ACCOUNTING MILLER 10 ACCOUNTING SQL> ed Wrote file afiedt.buf 1 2 3 4 5 6* SQL>

SELECT E.Ename, D.Deptno, D.Dname, D.Loc FROM Emp E, Dept D WHERE E.Deptno(+) = D.Deptno AND E.Deptno(+) = 10 ORDER BY E.Deptno / LOC ------------NEW YORK NEW YORK NEW YORK CHENNAI MUMBAI DALLAS CHICAGO DELHI BOSTON

ENAME DEPTNO DNAME ---------- ---------- -------------KING 10 ACCOUNTING CLARK 10 ACCOUNTING MILLER 10 ACCOUNTING 50 SHIPPING 60 CARGO 20 RESEARCH 30 SALES 70 COURIER 40 OPERATIONS 9 rows selected. SQL> ed Wrote file afiedt.buf 1 2 3 4 5 6 7 8 9 10* SQL>

SELECT NVL(E.Ename,'Not Requested OR Recruited') Ename, D.Deptno, D.Dname, D.Loc FROM Emp E, Dept D WHERE E.Deptno(+) = D.Deptno AND E.Deptno(+) = 10 ORDER BY E.Deptno / LOC ------------NEW YORK NEW YORK NEW YORK CHENNAI MUMBAI

ENAME DEPTNO DNAME -------------------------- ---------- -------------KING 10 ACCOUNTING CLARK 10 ACCOUNTING MILLER 10 ACCOUNTING Not Requested OR Recruited 50 SHIPPING Not Requested OR Recruited 60 CARGO

Not Not Not Not

Requested Requested Requested Requested

OR OR OR OR

Recruited Recruited Recruited Recruited

20 30 70 40

RESEARCH SALES COURIER OPERATIONS

DALLAS CHICAGO DELHI BOSTON

9 rows selected. SQL> ed Wrote file afiedt.buf 1 2 3 4 5 6 7 8 9 10* SQL> SELECT NVL(E.Ename,'Not Requested OR Recruited') Ename, D.Deptno, D.Dname, D.Loc FROM Emp E, Dept D WHERE E.Deptno = D.Deptno(+) AND E.Deptno(+) = 10 ORDER BY E.Deptno / LOC ------------NEW YORK NEW YORK NEW YORK

ENAME DEPTNO DNAME -------------------------- ---------- -------------KING 10 ACCOUNTING CLARK 10 ACCOUNTING MILLER 10 ACCOUNTING SQL> cl scr SQL> ed Wrote file afiedt.buf 1 2 3 4 5* SQL> SELECT E.Ename Employee, NVL(M.Ename, 'Supreme Authority') Manager FROM Emp E, Emp M WHERE E.MGR = M.Empno / MANAGER ----------------KING KING KING BLAKE BLAKE BLAKE BLAKE BLAKE CLARK JONES JONES MANAGER ----------------FORD SCOTT

EMPLOYEE ---------JONES CLARK BLAKE WARD JAMES TURNER ALLEN MARTIN MILLER SCOTT FORD EMPLOYEE ---------SMITH ADAMS

13 rows selected.

SQL> ed Wrote file afiedt.buf 1 2 3 4 5* SQL> SELECT E.Ename Employee, NVL(M.Ename, 'Supreme Authority') Manager FROM Emp E, Emp M WHERE E.MGR = M.Empno(+) / MANAGER ----------------KING KING KING BLAKE BLAKE BLAKE BLAKE BLAKE CLARK JONES JONES MANAGER ----------------FORD SCOTT Supreme Authority

EMPLOYEE ---------JONES CLARK BLAKE WARD JAMES TURNER ALLEN MARTIN MILLER SCOTT FORD EMPLOYEE ---------SMITH ADAMS KING

14 rows selected. SQL> cl scr SQL> 2 3 4 5 6 SELECT C.Name, O.OrdID, I.ItemID, I.Itemtot, O.Total FROM Customer C, Ord O, Item I WHERE C.CustID = O.CustID AND O.OrdID = I.OrdID;

NAME ORDID ITEMID ITEMTOT --------------------------------------------- ---------- ---------- ---------TOTAL ---------TKB SPORT SHOP 610 3 58 101.4 VOLLYRITE 45 EVERY MOUNTAIN 5860 611 612 1 1 45 3000

NAME ORDID ITEMID ITEMTOT --------------------------------------------- ---------- ---------- ---------TOTAL ----------

SHAPE UP 2.4 VOLLYRITE 56 SHAPE UP 698

601 602 604

1 1 1

2.4 56 174

NAME ORDID ITEMID ITEMTOT --------------------------------------------- ---------- ---------- ---------TOTAL ---------SHAPE UP 604 2 84 698 SHAPE UP 698 VOLLYRITE 224 604 603 3 2 440 224

NAME ORDID ITEMID ITEMTOT --------------------------------------------- ---------- ---------- ---------TOTAL ---------TKB SPORT SHOP 610 1 35 101.4 TKB SPORT SHOP 101.4 NORTH WOODS HEALTH AND FITNESS SUPPLY CENTER 6400 610 613 2 4 8.4 440

NAME ORDID ITEMID ITEMTOT --------------------------------------------- ---------- ---------- ---------TOTAL ---------VOLLYRITE 614 1 15540 23940 VOLLYRITE 23940 EVERY MOUNTAIN 5860 614 612 2 2 2800 810

NAME ORDID ITEMID ITEMTOT --------------------------------------------- ---------- ---------- ---------TOTAL ---------EVERY MOUNTAIN 612 3 1500 5860 JOCKSPORTS 620 1 350

4450 JOCKSPORTS 4450 620 2 2400

NAME ORDID ITEMID ITEMTOT --------------------------------------------- ---------- ---------- ---------TOTAL ---------JOCKSPORTS 620 3 1700 4450 NORTH WOODS HEALTH AND FITNESS SUPPLY CENTER 6400 NORTH WOODS HEALTH AND FITNESS SUPPLY CENTER 6400 613 613 1 2 560 4800

NAME ORDID ITEMID ITEMTOT --------------------------------------------- ---------- ---------- ---------TOTAL ---------NORTH WOODS HEALTH AND FITNESS SUPPLY CENTER 613 3 600 6400 EVERY MOUNTAIN 1260 K + T SPORTS 46370 619 617 3 1 340 1750

NAME ORDID ITEMID ITEMTOT --------------------------------------------- ---------- ---------- ---------TOTAL ---------K + T SPORTS 617 2 4500 46370 VOLLYRITE 23940 JUST TENNIS 764 614 616 3 1 5600 450

NAME ORDID ITEMID ITEMTOT --------------------------------------------- ---------- ---------- ---------TOTAL ---------JUST TENNIS 616 2 140 764 JUST TENNIS 764 JUST TENNIS 764 616 616 3 4 116 34

NAME ORDID ITEMID ITEMTOT --------------------------------------------- ---------- ---------- ---------TOTAL ---------JUST TENNIS 616 5 24 764 EVERY MOUNTAIN 1260 EVERY MOUNTAIN 1260 619 619 1 2 400 240

NAME ORDID ITEMID ITEMTOT --------------------------------------------- ---------- ---------- ---------TOTAL ---------WOMENS SPORTS 615 1 180 710 EVERY MOUNTAIN 5.6 WOMENS SPORTS 710 607 615 1 2 5.6 280

NAME ORDID ITEMID ITEMTOT --------------------------------------------- ---------- ---------- ---------TOTAL ---------K + T SPORTS 617 3 1400 46370 K + T SPORTS 46370 K + T SPORTS 46370 617 617 4 5 2800 29000

NAME ORDID ITEMID ITEMTOT --------------------------------------------- ---------- ---------- ---------TOTAL ---------K + T SPORTS 617 6 2400 46370 K + T SPORTS 46370 K + T SPORTS 46370 617 617 7 8 2500 340

NAME ORDID ITEMID ITEMTOT --------------------------------------------- ---------- ---------- ----------

TOTAL ---------K + T SPORTS 46370 K + T SPORTS 46370 JOCKSPORTS 97.5

617 617 609

9 10 2

480 1200 12.5

NAME ORDID ITEMID ITEMTOT --------------------------------------------- ---------- ---------- ---------TOTAL ---------JOCKSPORTS 609 3 50 97.5 VOLLYRITE 3510.5 VOLLYRITE 3510.5 618 618 1 2 805 2255.5

NAME ORDID ITEMID ITEMTOT --------------------------------------------- ---------- ---------- ---------TOTAL ---------VOLLYRITE 618 3 450 3510.5 JOCKSPORTS 730 JOCKSPORTS 730 621 621 1 2 450 280

NAME ORDID ITEMID ITEMTOT --------------------------------------------- ---------- ---------- ---------TOTAL ---------WOMENS SPORTS 615 3 250 710 EVERY MOUNTAIN 35.2 EVERY MOUNTAIN 35.2 608 608 1 2 24 11.2

NAME ORDID ITEMID ITEMTOT --------------------------------------------- ---------- ---------- ---------TOTAL ---------JOCKSPORTS 609 1 35 97.5

JOCKSPORTS 3.4 SHAPE UP 8324

606 605

1 1

3.4 4500

NAME ORDID ITEMID ITEMTOT --------------------------------------------- ---------- ---------- ---------TOTAL ---------SHAPE UP 605 2 1400 8324 SHAPE UP 8324 SHAPE UP 8324 605 605 3 4 290 1200

NAME ORDID ITEMID ITEMTOT --------------------------------------------- ---------- ---------- ---------TOTAL ---------SHAPE UP 605 5 900 8324 SHAPE UP 8324 EVERY MOUNTAIN 5860 605 612 6 4 34 550

NAME ORDID ITEMID ITEMTOT --------------------------------------------- ---------- ---------- ---------TOTAL ---------EVERY MOUNTAIN 619 4 280 1260 64 rows selected. SQL> cl scr SQL> 2 3 4 5 6 7 8 SELECT E.Ename Employee, E.Deptno Department, M.Ename Manager, M.Deptno "Manager's Dept" FROM Emp E, Dept D, Emp M WHERE E.MGR = M.Empno AND E.Deptno = D.Deptno;

EMPLOYEE DEPARTMENT MANAGER Manager's Dept ---------- ---------- ---------- -------------JONES 20 KING 10

CLARK BLAKE WARD JAMES TURNER ALLEN MARTIN MILLER SCOTT FORD

10 30 30 30 30 30 30 10 20 20

KING KING BLAKE BLAKE BLAKE BLAKE BLAKE CLARK JONES JONES

10 10 30 30 30 30 30 10 20 20

EMPLOYEE DEPARTMENT MANAGER Manager's Dept ---------- ---------- ---------- -------------SMITH 20 FORD 20 ADAMS 20 SCOTT 20 13 rows selected. SQL> cl scr SQL> 2 3 4 5 6 7 8 9 SELECT E.Ename Employee, Dname Department, Loc Place, M.Ename Manager, Dname "Manager's Dept" FROM Emp E, Dept D, Emp M WHERE E.MGR = M.Empno AND E.Deptno = D.Deptno; DEPARTMENT -------------RESEARCH ACCOUNTING SALES SALES SALES SALES SALES SALES ACCOUNTING RESEARCH RESEARCH DEPARTMENT -------------RESEARCH RESEARCH PLACE ------------DALLAS NEW YORK CHICAGO CHICAGO CHICAGO CHICAGO CHICAGO CHICAGO NEW YORK DALLAS DALLAS PLACE ------------DALLAS DALLAS MANAGER ---------KING KING KING BLAKE BLAKE BLAKE BLAKE BLAKE CLARK JONES JONES MANAGER ---------FORD SCOTT Manager's Dept -------------RESEARCH ACCOUNTING SALES SALES SALES SALES SALES SALES ACCOUNTING RESEARCH RESEARCH Manager's Dept -------------RESEARCH RESEARCH

EMPLOYEE ---------JONES CLARK BLAKE WARD JAMES TURNER ALLEN MARTIN MILLER SCOTT FORD EMPLOYEE ---------SMITH ADAMS

13 rows selected. SQL> cl scr SQL> 2 3 4 5 6 7 SELECT E.Ename Employee, DE.Dname Department, DE.Loc Place, M.Ename Manager, DM.Dname "Manager's Dept" FROM Emp E, Dept DE, Emp M, Dept DM

8 WHERE E.MGR = M.Empno AND 9 E.Deptno = DE.Deptno AND 10 M.Deptno = DM.Deptno 11 ORDER BY E.Deptno; EMPLOYEE ---------MILLER CLARK JONES SMITH SCOTT FORD ADAMS BLAKE MARTIN ALLEN TURNER EMPLOYEE ---------JAMES WARD DEPARTMENT -------------ACCOUNTING ACCOUNTING RESEARCH RESEARCH RESEARCH RESEARCH RESEARCH SALES SALES SALES SALES DEPARTMENT -------------SALES SALES PLACE ------------NEW YORK NEW YORK DALLAS DALLAS DALLAS DALLAS DALLAS CHICAGO CHICAGO CHICAGO CHICAGO PLACE ------------CHICAGO CHICAGO MANAGER ---------CLARK KING KING FORD JONES JONES SCOTT KING BLAKE BLAKE BLAKE MANAGER ---------BLAKE BLAKE Manager's Dept -------------ACCOUNTING ACCOUNTING ACCOUNTING RESEARCH RESEARCH RESEARCH RESEARCH ACCOUNTING SALES SALES SALES Manager's Dept -------------SALES SALES

13 rows selected. SQL> cl scr SQL> 2 3 4 5 6 7 8 9 SELECT E.Ename Employee, E.Sal "Employee's Salary", M.Ename Manager, M.Sal "Manager's Salary", Dname "Manager's Dept" FROM Emp E, Dept D, Emp M WHERE E.Deptno = D.Deptno AND E.MGR = M.Empno; MANAGER Manager's Salary ---------- ---------------KING 5000 KING 5000 KING 5000 BLAKE 2850 BLAKE 2850 BLAKE 2850 BLAKE 2850 BLAKE 2850 CLARK 2450 JONES 2975 JONES 2975 MANAGER Manager's Salary ---------- ---------------FORD 3000 SCOTT 3000 Manager's Dept -------------RESEARCH ACCOUNTING SALES SALES SALES SALES SALES SALES ACCOUNTING RESEARCH RESEARCH Manager's Dept -------------RESEARCH RESEARCH

EMPLOYEE Employee's Salary ---------- ----------------JONES 2975 CLARK 2450 BLAKE 2850 WARD 1250 JAMES 950 TURNER 1500 ALLEN 1600 MARTIN 1250 MILLER 1300 SCOTT 3000 FORD 3000 EMPLOYEE Employee's Salary ---------- ----------------SMITH 800 ADAMS 1100 13 rows selected. SQL> cl scr

SQL> 2 3 4 5 6 7 8 9 10

SELECT E.Ename Employee, E.Sal "Employee's Salary", M.Ename Manager, M.Sal "Manager's Salary", DM.Dname "Manager's Dept" FROM Emp E, Dept DE, Emp M, Dept DM WHERE E.Deptno = DE.Deptno AND M.Deptno = DM.Deptno AND E.MGR = M.Empno; MANAGER Manager's Salary ---------- ---------------KING 5000 KING 5000 KING 5000 BLAKE 2850 BLAKE 2850 BLAKE 2850 BLAKE 2850 BLAKE 2850 JONES 2975 FORD 3000 JONES 2975 MANAGER Manager's Salary ---------- ---------------SCOTT 3000 CLARK 2450 Manager's Dept -------------ACCOUNTING ACCOUNTING ACCOUNTING SALES SALES SALES SALES SALES RESEARCH RESEARCH RESEARCH Manager's Dept -------------RESEARCH ACCOUNTING

EMPLOYEE Employee's Salary ---------- ----------------BLAKE 2850 CLARK 2450 JONES 2975 MARTIN 1250 ALLEN 1600 TURNER 1500 JAMES 950 WARD 1250 FORD 3000 SMITH 800 SCOTT 3000 EMPLOYEE Employee's Salary ---------- ----------------ADAMS 1100 MILLER 1300 13 rows selected. SQL> cl scr SQL> SQL> SQL> SQL> SQL> 2 3 4 5 6 7 8 9 10

COLUMN Employee FORMAT A14 COLUMN "Employee's Dept" FORMAT A10 COLUMN Manager FORMAT A15 COLUMN "Manager's Dept" FORMAT A15 SELECT NVL(E.Ename, 'Not Recruited') Employee, DE.Dname "Employee's Dept", NVL(M.Ename, 'NULL Manager') Manager, NVL(DM.Dname, 'Not Recruited') "Manager's Dept", DE.Deptno FROM Emp E, Dept DE, Emp M, Dept DM WHERE E.Deptno(+) = DE.Deptno AND M.Deptno = DM.Deptno(+) AND E.MGR = M.Empno(+); Employee's ---------ACCOUNTING SALES ACCOUNTING RESEARCH RESEARCH RESEARCH RESEARCH RESEARCH MANAGER --------------CLARK KING KING KING SCOTT FORD JONES JONES Manager's Dept DEPTNO --------------- ---------ACCOUNTING 10 ACCOUNTING 30 ACCOUNTING 10 ACCOUNTING 20 RESEARCH 20 RESEARCH 20 RESEARCH 20 RESEARCH 20

EMPLOYEE -------------MILLER BLAKE CLARK JONES ADAMS SMITH FORD SCOTT

MARTIN ALLEN TURNER EMPLOYEE -------------JAMES WARD KING Not Recruited Not Recruited Not Recruited Not Recruited

SALES SALES SALES Employee's ---------SALES SALES ACCOUNTING SHIPPING CARGO COURIER OPERATIONS

BLAKE BLAKE BLAKE MANAGER --------------BLAKE BLAKE NULL Manager NULL Manager NULL Manager NULL Manager NULL Manager

SALES SALES SALES

30 30 30

Manager's Dept DEPTNO --------------- ---------SALES 30 SALES 30 Not Recruited 10 Not Recruited 50 Not Recruited 60 Not Recruited 70 Not Recruited 40

18 rows selected. SQL> cl scr SQL> SQL> SQL> SQL> SQL> 2 3 4 5 6 7 8 9 10 11 12 COLUMN "Employee's Salary" FORMAT 9999 COLUMN EMPGRADE FORMAT 99 COLUMN "Manager's Salary" FORMAT 9999 COLUMN MGRGRADE FORMAT 99 SELECT E.Ename Employee, E.Sal "Employee's Salary", SE.Grade EmpGrade, M.Sal "Manager's Salary", SM.Grade MGRGrade, Dname FROM Emp E, Dept D, Emp M, SalGrade SE, SalGrade SM WHERE E.Deptno = D.Deptno AND E.MGR = M.Empno AND E.Sal BETWEEN SE.LoSal AND SE.HiSal AND M.Sal BETWEEN SM.LoSal AND SM.HiSal;

EMPLOYEE Employee's Salary EMPGRADE Manager's Salary MGRGRADE -------------- ----------------- -------- ---------------- -------DNAME -------------SMITH 800 1 3000 4 RESEARCH JAMES SALES ADAMS RESEARCH 950 1100 1 1 2850 3000 4 4

EMPLOYEE Employee's Salary EMPGRADE Manager's Salary MGRGRADE -------------- ----------------- -------- ---------------- -------DNAME -------------MARTIN 1250 2 2850 4 SALES WARD SALES MILLER 1250 1300 2 2 2850 2450 4 4

ACCOUNTING EMPLOYEE Employee's Salary EMPGRADE Manager's Salary MGRGRADE -------------- ----------------- -------- ---------------- -------DNAME -------------TURNER 1500 3 2850 4 SALES ALLEN SALES CLARK ACCOUNTING 1600 2450 3 4 2850 5000 4 5

EMPLOYEE Employee's Salary EMPGRADE Manager's Salary MGRGRADE -------------- ----------------- -------- ---------------- -------DNAME -------------BLAKE 2850 4 5000 5 SALES JONES RESEARCH FORD RESEARCH 2975 3000 4 4 5000 2975 5 4

EMPLOYEE Employee's Salary EMPGRADE Manager's Salary MGRGRADE -------------- ----------------- -------- ---------------- -------DNAME -------------SCOTT 3000 4 2975 4 RESEARCH 13 rows selected. SQL> SPOOL OFF