Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Spool File For Oracle Students Trained by Sathish Yellanki

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Spool File For Oracle Students Trained By Sathish Yellanki

SQL> cl scr

SQL> SELECT
2 Emp.Empno,
3 Emp.Ename,
4 Emp.Deptno,
5 Dept.Deptno,
6 Dept.Dname,
7 Dept.Loc
8 FROM Emp, Dept
9 WHERE Emp.Deptno = Dept.Deptno;

EMPNO ENAME DEPTNO DEPTNO DNAME LOC


---------- ---------- ---------- ---------- -------------- -------------
7839 KING 10 10 ACCOUNTING NEW YORK
7698 BLAKE 30 30 SALES CHICAGO
7782 CLARK 10 10 ACCOUNTING NEW YORK
7566 JONES 20 20 RESEARCH DALLAS
7654 MARTIN 30 30 SALES CHICAGO
7499 ALLEN 30 30 SALES CHICAGO
7844 TURNER 30 30 SALES CHICAGO
7900 JAMES 30 30 SALES CHICAGO
7521 WARD 30 30 SALES CHICAGO
7902 FORD 20 20 RESEARCH DALLAS
7369 SMITH 20 20 RESEARCH DALLAS

EMPNO ENAME DEPTNO DEPTNO DNAME LOC


---------- ---------- ---------- ---------- -------------- -------------
7788 SCOTT 20 20 RESEARCH DALLAS
7876 ADAMS 20 20 RESEARCH DALLAS
7934 MILLER 10 10 ACCOUNTING NEW YORK

14 rows selected.

SQL> ED
Wrote file afiedt.buf

1 SELECT
2 Emp.Empno,
3 Emp.Ename,
4 Dept.Dname,
5 Dept.Loc
6 FROM Emp, Dept
7* WHERE Emp.Deptno = Dept.Deptno
SQL> /

EMPNO ENAME DNAME LOC


---------- ---------- -------------- -------------
7839 KING ACCOUNTING NEW YORK
7698 BLAKE SALES CHICAGO
7782 CLARK ACCOUNTING NEW YORK
7566 JONES RESEARCH DALLAS
7654 MARTIN SALES CHICAGO
7499 ALLEN SALES CHICAGO
7844 TURNER SALES CHICAGO
7900 JAMES SALES CHICAGO
7521 WARD SALES CHICAGO
7902 FORD RESEARCH DALLAS
7369 SMITH RESEARCH DALLAS

SkyEss Techno Solutions Pvt. Ltd.


Flat No. 201, II Floor, Abhilash Towers, BK Guda, Hyderabad – 500 038
Ph No. +9140 23710047, 64640047, Mobile: 9985798869
Contact For Courses And Training in
Oracle Developer Suite 10g(D2K), Oracle Apps R12, Live Projects in SQL And PL/SQL
Spool File For Oracle Students Trained By Sathish Yellanki

EMPNO ENAME DNAME LOC


---------- ---------- -------------- -------------
7788 SCOTT RESEARCH DALLAS
7876 ADAMS RESEARCH DALLAS
7934 MILLER ACCOUNTING NEW YORK

14 rows selected.

SQL> Select
2 Empno,
3 Ename,
4 Emp.Deptno,
5 Loc
6 FROM Emp, Dept
7 WHERE Emp.Deptno = Dept.Deptno AND
8 Job = UPPER('manager');

EMPNO ENAME DEPTNO LOC


---------- ---------- ---------- -------------
7698 BLAKE 30 CHICAGO
7782 CLARK 10 NEW YORK
7566 JONES 20 DALLAS

SQL> Select
2 Empno,
3 Ename,
4 Sal,
5 Sal * 12 AnnSal,
6 Emp.Deptno,
7 Loc
8 FROM Emp, Dept
9 WHERE Emp.Deptno = Dept.Deptno;

EMPNO ENAME SAL ANNSAL DEPTNO LOC


---------- ---------- ---------- ---------- ---------- -------------
7839 KING 5000 60000 10 NEW YORK
7698 BLAKE 2850 34200 30 CHICAGO
7782 CLARK 2450 29400 10 NEW YORK
7566 JONES 2975 35700 20 DALLAS
7654 MARTIN 1250 15000 30 CHICAGO
7499 ALLEN 1600 19200 30 CHICAGO
7844 TURNER 1500 18000 30 CHICAGO
7900 JAMES 950 11400 30 CHICAGO
7521 WARD 1250 15000 30 CHICAGO
7902 FORD 3000 36000 20 DALLAS
7369 SMITH 800 9600 20 DALLAS

EMPNO ENAME SAL ANNSAL DEPTNO LOC


---------- ---------- ---------- ---------- ---------- -------------
7788 SCOTT 3000 36000 20 DALLAS
7876 ADAMS 1100 13200 20 DALLAS
7934 MILLER 1300 15600 10 NEW YORK

14 rows selected.

SQL> Select
2 Dept.Deptno,
3 Dname,

SkyEss Techno Solutions Pvt. Ltd.


Flat No. 201, II Floor, Abhilash Towers, BK Guda, Hyderabad – 500 038
Ph No. +9140 23710047, 64640047, Mobile: 9985798869
Contact For Courses And Training in
Oracle Developer Suite 10g(D2K), Oracle Apps R12, Live Projects in SQL And PL/SQL
Spool File For Oracle Students Trained By Sathish Yellanki

4 Loc,
5 SUM(Sal)
6 FROM Emp, Dept
7 WHERE Emp.Deptno = Dept.Deptno
8 GROUP BY Dept.Deptno, Dname, Loc;

DEPTNO DNAME LOC SUM(SAL)


---------- -------------- ------------- ----------
10 ACCOUNTING NEW YORK 8750
20 RESEARCH DALLAS 10875
30 SALES CHICAGO 9400

SQL> Select
2 TO_CHAR(HireDate, 'YYYY') Year,
3 Dept.Deptno,
4 Dname,
5 SUM(Sal)
6 FROM Emp, Dept
7 WHERE Emp.Deptno = Dept.Deptno
8 GROUP BY TO_CHAR(HireDate, 'YYYY'), Dept.Deptno, Dname
9 ORDER BY Year;

YEAR DEPTNO DNAME SUM(SAL)


---- ---------- -------------- ----------
1980 20 RESEARCH 800
1981 10 ACCOUNTING 7450
1981 20 RESEARCH 5975
1981 30 SALES 9400
1982 10 ACCOUNTING 1300
1982 20 RESEARCH 3000
1983 20 RESEARCH 1100

7 rows selected.

SQL> cl scr

SQL> Select
2 TO_CHAR(HireDate, 'YYYY') Year,
3 Dept.Deptno,
4 Dname,
5 SUM(Sal)
6 FROM Emp, Dept
7 WHERE Emp.Deptno = Dept.Deptno
8 GROUP BY TO_CHAR(HireDate, 'YYYY'), Dept.Deptno, Dname
9 HAVING COUNT(TO_CHAR(HireDate, 'YYYY')) > 2
10 ORDER BY Year;

YEAR DEPTNO DNAME SUM(SAL)


---- ---------- -------------- ----------
1981 30 SALES 9400

SQL> cl scr

SQL> SELECT
2 E.Empno,
3 E.Ename,
4 D.Deptno,
5 D.Dname
6 FROM Emp E, Dept D

SkyEss Techno Solutions Pvt. Ltd.


Flat No. 201, II Floor, Abhilash Towers, BK Guda, Hyderabad – 500 038
Ph No. +9140 23710047, 64640047, Mobile: 9985798869
Contact For Courses And Training in
Oracle Developer Suite 10g(D2K), Oracle Apps R12, Live Projects in SQL And PL/SQL
Spool File For Oracle Students Trained By Sathish Yellanki

7 WHERE E.Deptno = D.Deptno;

EMPNO ENAME DEPTNO DNAME


---------- ---------- ---------- --------------
7839 KING 10 ACCOUNTING
7698 BLAKE 30 SALES
7782 CLARK 10 ACCOUNTING
7566 JONES 20 RESEARCH
7654 MARTIN 30 SALES
7499 ALLEN 30 SALES
7844 TURNER 30 SALES
7900 JAMES 30 SALES
7521 WARD 30 SALES
7902 FORD 20 RESEARCH
7369 SMITH 20 RESEARCH

EMPNO ENAME DEPTNO DNAME


---------- ---------- ---------- --------------
7788 SCOTT 20 RESEARCH
7876 ADAMS 20 RESEARCH
7934 MILLER 10 ACCOUNTING

14 rows selected.

SQL> ED
Wrote file afiedt.buf

1 SELECT
2 Emp.Empno,
3 E.Ename,
4 D.Deptno,
5 D.Dname
6 FROM Emp E, Dept D
7* WHERE E.Deptno = D.Deptno
SQL> /
Emp.Empno,
*
ERROR at line 2:
ORA-00904: "EMP"."EMPNO": invalid identifier

SQL> ED
Wrote file afiedt.buf

1 SELECT
2 Employee.Empno,
3 Employee.Ename,
4 Department.Deptno,
5 Department.Dname
6 FROM Emp Employee, Dept Department
7* WHERE Employee.Deptno = Department.Deptno
SQL> /

EMPNO ENAME DEPTNO DNAME


---------- ---------- ---------- --------------
7839 KING 10 ACCOUNTING
7698 BLAKE 30 SALES
7782 CLARK 10 ACCOUNTING
7566 JONES 20 RESEARCH

SkyEss Techno Solutions Pvt. Ltd.


Flat No. 201, II Floor, Abhilash Towers, BK Guda, Hyderabad – 500 038
Ph No. +9140 23710047, 64640047, Mobile: 9985798869
Contact For Courses And Training in
Oracle Developer Suite 10g(D2K), Oracle Apps R12, Live Projects in SQL And PL/SQL
Spool File For Oracle Students Trained By Sathish Yellanki

7654 MARTIN 30 SALES


7499 ALLEN 30 SALES
7844 TURNER 30 SALES
7900 JAMES 30 SALES
7521 WARD 30 SALES
7902 FORD 20 RESEARCH
7369 SMITH 20 RESEARCH

EMPNO ENAME DEPTNO DNAME


---------- ---------- ---------- --------------
7788 SCOTT 20 RESEARCH
7876 ADAMS 20 RESEARCH
7934 MILLER 10 ACCOUNTING

14 rows selected.

SQL> ED
Wrote file afiedt.buf

1 SELECT
2 E.Ename,
3 E.Job,
4 D.Deptno,
5 D.Dname,
6 D.Loc
7 FROM Emp E, Dept D
8 WHERE E.Deptno = D.Deptno AND
9* E.Job IN('ANALYST', 'MANAGER' )
SQL> /

ENAME JOB DEPTNO DNAME LOC


---------- --------- ---------- -------------- -------------
BLAKE MANAGER 30 SALES CHICAGO
CLARK MANAGER 10 ACCOUNTING NEW YORK
JONES MANAGER 20 RESEARCH DALLAS
FORD ANALYST 20 RESEARCH DALLAS
SCOTT ANALYST 20 RESEARCH DALLAS

SQL> SELECT
2 E.Ename,
3 E.Job,
4 D.Dname,
5 D.Loc
6 FROM Emp E, Dept D
7 WHERE E.Deptno = D.Deptno AND
8 D.Dname <> 'SALES';

ENAME JOB DNAME LOC


---------- --------- -------------- -------------
KING PRESIDENT ACCOUNTING NEW YORK
CLARK MANAGER ACCOUNTING NEW YORK
JONES MANAGER RESEARCH DALLAS
FORD ANALYST RESEARCH DALLAS
SMITH CLERK RESEARCH DALLAS
SCOTT ANALYST RESEARCH DALLAS
ADAMS CLERK RESEARCH DALLAS
MILLER CLERK ACCOUNTING NEW YORK

8 rows selected.

SkyEss Techno Solutions Pvt. Ltd.


Flat No. 201, II Floor, Abhilash Towers, BK Guda, Hyderabad – 500 038
Ph No. +9140 23710047, 64640047, Mobile: 9985798869
Contact For Courses And Training in
Oracle Developer Suite 10g(D2K), Oracle Apps R12, Live Projects in SQL And PL/SQL
Spool File For Oracle Students Trained By Sathish Yellanki

SQL> ED
Wrote file afiedt.buf

1 SELECT
2 E.Ename,
3 E.Job,
4 E.Sal,
5 E.HireDate
6 FROM Emp E, Dept D
7 WHERE E.Deptno = D.Deptno AND
8* D.Dname = 'SALES'
SQL> /

ENAME JOB SAL HIREDATE


---------- --------- ---------- ---------
BLAKE MANAGER 2850 01-MAY-81
MARTIN SALESMAN 1250 28-SEP-81
ALLEN SALESMAN 1600 20-FEB-81
TURNER SALESMAN 1500 08-SEP-81
JAMES CLERK 950 03-DEC-81
WARD SALESMAN 1250 22-FEB-81

6 rows selected.

SQL> cl scr

SQL> SELECT Empno, Ename, Mgr, Job


2 FROM EMp;

EMPNO ENAME MGR JOB


---------- ---------- ---------- ---------
7839 KING PRESIDENT
7698 BLAKE 7839 MANAGER
7782 CLARK 7839 MANAGER
7566 JONES 7839 MANAGER
7654 MARTIN 7698 SALESMAN
7499 ALLEN 7698 SALESMAN
7844 TURNER 7698 SALESMAN
7900 JAMES 7698 CLERK
7521 WARD 7698 SALESMAN
7902 FORD 7566 ANALYST
7369 SMITH 7902 CLERK

EMPNO ENAME MGR JOB


---------- ---------- ---------- ---------
7788 SCOTT 7566 ANALYST
7876 ADAMS 7788 CLERK
7934 MILLER 7782 CLERK

14 rows selected.

SQL> cl scr

SQL> SELECT Ename Employee, Ename Manager


2 FROM Emp, Emp;
SELECT Ename Employee, Ename Manager
*
ERROR at line 1:

SkyEss Techno Solutions Pvt. Ltd.


Flat No. 201, II Floor, Abhilash Towers, BK Guda, Hyderabad – 500 038
Ph No. +9140 23710047, 64640047, Mobile: 9985798869
Contact For Courses And Training in
Oracle Developer Suite 10g(D2K), Oracle Apps R12, Live Projects in SQL And PL/SQL
Spool File For Oracle Students Trained By Sathish Yellanki

ORA-00918: column ambiguously defined

SQL> cl scr

SQL> SELECT
2 E1.Ename "Employee Name",
3 E2. Ename "Managers Name"
4 FROM Emp E1, Emp E2
5 WHERE E1.Mgr = E2.Empno;

Employee N Managers N
---------- ----------
JONES KING
CLARK KING
BLAKE KING
WARD BLAKE
JAMES BLAKE
TURNER BLAKE
ALLEN BLAKE
MARTIN BLAKE
MILLER CLARK
SCOTT JONES
FORD JONES

Employee N Managers N
---------- ----------
SMITH FORD
ADAMS SCOTT

13 rows selected.

SQL> ED
Wrote file afiedt.buf

1 SELECT
2 Employees.Ename Employee,
3 Managers.Ename Manager
4 FROM Emp Employees, Emp Managers
5* WHERE Employees.Mgr = Managers.Empno
SQL> /

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

EMPLOYEE MANAGER
---------- ----------
SMITH FORD

SkyEss Techno Solutions Pvt. Ltd.


Flat No. 201, II Floor, Abhilash Towers, BK Guda, Hyderabad – 500 038
Ph No. +9140 23710047, 64640047, Mobile: 9985798869
Contact For Courses And Training in
Oracle Developer Suite 10g(D2K), Oracle Apps R12, Live Projects in SQL And PL/SQL
Spool File For Oracle Students Trained By Sathish Yellanki

ADAMS SCOTT

13 rows selected.

SQL> ED
Wrote file afiedt.buf

1 SELECT
2 Employees.Ename Manager,
3 Managers.Ename Employee
4 FROM Emp Employees, Emp Managers
5* WHERE Employees.Mgr = Managers.Empno
SQL> /

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

MANAGER EMPLOYEE
---------- ----------
SMITH FORD
ADAMS SCOTT

13 rows selected.

SQL> ED
Wrote file afiedt.buf

1 SELECT
2 Managers.Ename Manager,
3 Employees.Ename Employee
4 FROM Emp Employees, Emp Managers
5* WHERE Employees.Mgr = Managers.Empno
SQL> /

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

SkyEss Techno Solutions Pvt. Ltd.


Flat No. 201, II Floor, Abhilash Towers, BK Guda, Hyderabad – 500 038
Ph No. +9140 23710047, 64640047, Mobile: 9985798869
Contact For Courses And Training in
Oracle Developer Suite 10g(D2K), Oracle Apps R12, Live Projects in SQL And PL/SQL
Spool File For Oracle Students Trained By Sathish Yellanki

MANAGER EMPLOYEE
---------- ----------
FORD SMITH
SCOTT ADAMS

13 rows selected.

SQL> ED
Wrote file afiedt.buf

1 SELECT
2 Employees.Ename Employee,
3 Managers.Ename Manager
4 FROM Emp Employees, Emp Managers
5* WHERE Employees.Mgr = Managers.Empno
SQL> /

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

EMPLOYEE MANAGER
---------- ----------
SMITH FORD
ADAMS SCOTT

13 rows selected.

SQL> cl scr

SQL> SELECT
2 E1.Ename||'''s Manager is '||
3 E2.Ename "Employees And Managers"
4 FROM Emp E1, Emp E2
5 WHERE E1.Mgr = E2.Empno;

Employees And Managers


----------------------------------
JONES's Manager is KING
CLARK's Manager is KING
BLAKE's Manager is KING
WARD's Manager is BLAKE
JAMES's Manager is BLAKE
TURNER's Manager is BLAKE
ALLEN's Manager is BLAKE
MARTIN's Manager is BLAKE
MILLER's Manager is CLARK
SCOTT's Manager is JONES
FORD's Manager is JONES

SkyEss Techno Solutions Pvt. Ltd.


Flat No. 201, II Floor, Abhilash Towers, BK Guda, Hyderabad – 500 038
Ph No. +9140 23710047, 64640047, Mobile: 9985798869
Contact For Courses And Training in
Oracle Developer Suite 10g(D2K), Oracle Apps R12, Live Projects in SQL And PL/SQL
Spool File For Oracle Students Trained By Sathish Yellanki

Employees And Managers


----------------------------------
SMITH's Manager is FORD
ADAMS's Manager is SCOTT

13 rows selected.

SQL> www.skyess.info
SP2-0734: unknown command beginning "www.skyess..." - rest of line ignored.
SQL> SPOOL OFF

SkyEss Techno Solutions Pvt. Ltd.


Flat No. 201, II Floor, Abhilash Towers, BK Guda, Hyderabad – 500 038
Ph No. +9140 23710047, 64640047, Mobile: 9985798869
Contact For Courses And Training in
Oracle Developer Suite 10g(D2K), Oracle Apps R12, Live Projects in SQL And PL/SQL

You might also like