FROM Clause in SQL with Proper Explanation

FROM clause in SQL with Proper Explanation



Table 1:-  XX_EMP  A

select * from XX_EMP A

            
EMPNO
ENAME
JOB
MGR
HIREDATE
SAL
COMM
DEPTNO
7369
Sunil
CLERK
7902
17-Dec-80
800

20
7499
Anil
SALESMAN
7698
20-Feb-81
1600
300
30
7521
Sanjay
SALESMAN
7698
22-Feb-81
1250
500
30
7566
Jai Prakas
MANAGER
7839
02-Apr-81
2975

20
7654
Manoj
SALESMAN
7698
28-Sep-81
1250
1400
30
7698
Bal Kishan
MANAGER
7839
01-May-81
2850

30
7782
Anmol
MANAGER
7839
09-Jun-81
2450

10
7788
Sushil
ANALYST
7566
09-Dec-82
3000

20
7839
Kishan
PRESIDENT

17-Nov-81
5000

10
7844
Tarun
SALESMAN
7698
08-Sep-81
1500
0
30
7876
Amit
CLERK
7788
12-Jan-83
1100

20
7900
Jai
CLERK
7698
03-Dec-81
950

30
7902
Faiz
ANALYST
7566
03-Dec-81
3000

20
7934
Vinod
CLERK
7782
23-Jan-82
1300

10

Table 2:-  XX_DEPT B

select * from XX_DEPT B


DEPTNO
DNAME
LOC
10
ACCOUNTING
NEW YORK
20
RESEARCH
DALLAS
30
SALES
CHICAGO
40
OPERATIONS
BOSTON
--====================================================
-- TABLE
--====================================================


select * from XX_EMP A, XX_DEPT B
where A.DEPTNO = B.DEPTNO  

--====================================================
-- View
--====================================================

select * from XX_EMP

select * from XX_DEPT

CREATE OR REPLACE VIEW XX_DEPT_V AS
select DEPTNO DEPARTMENT_NO, DNAME NAME , LOC LOCATION , 'IN' COUNTY from XX_DEPT

select * from XX_DEPT_V

select * from XX_EMP , XX_DEPT_V
WHERE DEPTNO = DEPARTMENT_NO

--====================================================
-- Inline View
--====================================================


select * from XX_EMP A, ( select DEPTNO DEPARTMENT_NO, DNAME NAME , LOC LOCATION , 'IN' COUNTY from XX_DEPT ) B
WHERE DEPTNO = DEPARTMENT_NO




Comments

Popular posts from this blog

E-Text Report In Fusion | Types of E-Text reports

Supplier API's

How to pass default Parameter in cursor