Spool File For Oracle Students Trained by Sathish Yellanki
Spool File For Oracle Students Trained by Sathish Yellanki
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;
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> /
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');
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;
14 rows selected.
SQL> Select
2 Dept.Deptno,
3 Dname,
4 Loc,
5 SUM(Sal)
6 FROM Emp, Dept
7 WHERE Emp.Deptno = Dept.Deptno
8 GROUP BY Dept.Deptno, Dname, Loc;
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;
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;
SQL> cl scr
SQL> SELECT
2 E.Empno,
3 E.Ename,
4 D.Deptno,
5 D.Dname
6 FROM Emp E, Dept D
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> /
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> /
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';
8 rows selected.
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> /
6 rows selected.
SQL> cl scr
14 rows selected.
SQL> cl scr
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
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
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;
13 rows selected.
SQL> www.skyess.info
SP2-0734: unknown command beginning "www.skyess..." - rest of line ignored.
SQL> SPOOL OFF