Inline View In Oracle SQL




--=================== TABLE STRUCTURE =======================

XXSD_EMP_TL

EMPNO
ENAME
JOB
MGR
SAL
COMM
DEPTNO
7369
SMITH
CLERK
7902
800
80
20
7499
ALLEN
SALESMAN
7698
1600
300
30
7521
WARD
SALESMAN
7698
1250
500
30
7566
JONES
MANAGER
7839
2975
1200
20
7654
MARTIN
SALESMAN
7698
1250
1400
30
7698
BLAKE
MANAGER
7839
2850
1100
30
7782
CLARK
MANAGER
7839
2450
900
10
7788
SCOTT
ANALYST
7566
3000
750
20
7839
KING
PRESIDENT

5000
2000
10
7844
TURNER
SALESMAN
7698
1500
300
30
7876
ADAMS
CLERK
7788
1100
220
20
7900
JAMES
CLERK
7698
950
110
30
7902
FORD
ANALYST
7566
3000
700
20
7934
MILLER
CLERK
7782
1300
720
10


XXSD_DEPT_TL

DEPTNO
DNAME
LOC
DEPT_YEAR
10
ACCOUNTING
NEW YORK
2020
20
RESEARCH
DALLAS
2019
30
SALES
CHICAGO
2018
40
OPERATIONS
BOSTON
2017


--===================  In Line View========================

 select * from (  )

 CREATE OR REPLACE VIEW    XXSD_EMP_INFO_V AS
 select ENAME, JOB, MGR, A.DEPTNO, B.DNAME  from XXSD_EMP_TL A, XXSD_DEPT_TL B WHERE A.DEPTNO = B.DEPTNO

 select * from  XXSD_EMP_INFO_V


 --FROM--

 select * from ( )

 select * from ( select ENAME, JOB, MGR  from XXSD_EMP_TL ) --- SINGLE TABLE --- -- It Runs Only One Time—

ENAME
JOB
MGR
SMITH
CLERK
7902
ALLEN
SALESMAN
7698
WARD
SALESMAN
7698
JONES
MANAGER
7839
MARTIN
SALESMAN
7698
BLAKE
MANAGER
7839
CLARK
MANAGER
7839
SCOTT
ANALYST
7566
KING
PRESIDENT

TURNER
SALESMAN
7698
ADAMS
CLERK
7788
JAMES
CLERK
7698
FORD
ANALYST
7566
MILLER
CLERK
7782


 select * from ( select ENAME, JOB, MGR, A.DEPTNO, B.DNAME  from XXSD_EMP_TL A, XXSD_DEPT_TL B WHERE A.DEPTNO = B.DEPTNO  ) --- Multi TABLE --- -- It Runs Only One Time--


ENAME
JOB
MGR
DEPTNO
DNAME
SMITH
CLERK
7902
20
RESEARCH
ALLEN
SALESMAN
7698
30
SALES
WARD
SALESMAN
7698
30
SALES
JONES
MANAGER
7839
20
RESEARCH
MARTIN
SALESMAN
7698
30
SALES
BLAKE
MANAGER
7839
30
SALES
CLARK
MANAGER
7839
10
ACCOUNTING
SCOTT
ANALYST
7566
20
RESEARCH
KING
PRESIDENT

10
ACCOUNTING
TURNER
SALESMAN
7698
30
SALES
ADAMS
CLERK
7788
20
RESEARCH
JAMES
CLERK
7698
30
SALES
FORD
ANALYST
7566
20
RESEARCH
MILLER
CLERK
7782
10
ACCOUNTING

  
--====================================================
--  Join With Other Tables
--====================================================
 Inline View In Oracle SQL
--===============================================================================

select *
from ( select ENAME, JOB, MGR ,DEPTNO from XXSD_EMP_TL )   A, XXSD_DEPT_TL B
WHERE A.DEPTNO = B.DEPTNO



ENAME
JOB
MGR
DEPTNO
DEPTNO_1
DNAME
LOC
DEPT_YEAR
SMITH
CLERK
7902
20
20
RESEARCH
DALLAS
2019
ALLEN
SALESMAN
7698
30
30
SALES
CHICAGO
2018
WARD
SALESMAN
7698
30
30
SALES
CHICAGO
2018
JONES
MANAGER
7839
20
20
RESEARCH
DALLAS
2019
MARTIN
SALESMAN
7698
30
30
SALES
CHICAGO
2018
BLAKE
MANAGER
7839
30
30
SALES
CHICAGO
2018
CLARK
MANAGER
7839
10
10
ACCOUNTING
NEW YORK
2020
SCOTT
ANALYST
7566
20
20
RESEARCH
DALLAS
2019
KING
PRESIDENT

10
10
ACCOUNTING
NEW YORK
2020
TURNER
SALESMAN
7698
30
30
SALES
CHICAGO
2018
ADAMS
CLERK
7788
20
20
RESEARCH
DALLAS
2019
JAMES
CLERK
7698
30
30
SALES
CHICAGO
2018
FORD
ANALYST
7566
20
20
RESEARCH
DALLAS
2019
MILLER
CLERK
7782
10
10
ACCOUNTING
NEW YORK
2020

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