sql implicit joint


Joint data from 2 table:
SQL> desc dept
Name Null? Type
----------------------------------------- -------- -------------
DEPTNO NOT NULL NUMBER(2)
DNAME VARCHAR2(14)
LOC VARCHAR2(13)
SQL> desc emp
Name Null? Type
----------------------------------------- -------- -------------
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)
SQL> select * from dept;
Employee Salary statistics
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
SQL> select empno, ename, dname, loc
2 from emp, dept
3 where emp.deptno = dept.deptno;
Employee Salary statistics
EMPNO ENAME DNAME LOC
---------- ---------- -------------- -------------
7369 SMITH RESEARCH DALLAS
7499 ALLEN SALES CHICAGO
7521 WARD SALES CHICAGO
7566 JONES RESEARCH DALLAS
7654 MARTIN SALES CHICAGO
7698 BLAKE SALES CHICAGO
7782 CLARK ACCOUNTING NEW YORK
7788 SCOTT RESEARCH DALLAS
7839 KING ACCOUNTING NEW YORK
7844 TURNER SALES CHICAGO
7876 ADAMS RESEARCH DALLAS
7900 JAMES SALES CHICAGO
7902 FORD RESEARCH DALLAS
7934 MILLER ACCOUNTING NEW YORK
SQL>
EXAMPLE 2:
SQL> edit sql_implicit
select
emp.empno as "ID",
emp.ename as "NAME",
dept.dname as "DEPT.",
dept.loc as "LOCATION"
from
emp, dept
where
emp.deptno = dept.deptno;
SQL> start sql_implicit
Employee Salary statistics
ID NAME DEPT. LOCATION
---------- ---------- -------------- -------------
7369 SMITH RESEARCH DALLAS
7499 ALLEN SALES CHICAGO
7521 WARD SALES CHICAGO
7566 JONES RESEARCH DALLAS
7654 MARTIN SALES CHICAGO
7698 BLAKE SALES CHICAGO
7782 CLARK ACCOUNTING NEW YORK
7788 SCOTT RESEARCH DALLAS
7839 KING ACCOUNTING NEW YORK
7844 TURNER SALES CHICAGO
7876 ADAMS RESEARCH DALLAS
7900 JAMES SALES CHICAGO
7902 FORD RESEARCH DALLAS
7934 MILLER ACCOUNTING NEW YORK
SQL>
EXAMPLE 3:
SQL> edit sql_implicit2
select
e.empno as "ID",
INITCAP(e.ename) as "NAME",
INITCAP(d.dname) as "DEPT.",
INITCAP(d.loc) as "LOCATION"
from
emp e, dept d
where
e.deptno = d.deptno
order by
d.loc;
SQL> start sql_implicit2
Employee Salary statistics
ID NAME DEPT. LOCATION
---------- ---------- -------------- -------------
7499 Allen Sales Chicago
7521 Ward Sales Chicago
7654 Martin Sales Chicago
7900 James Sales Chicago
7844 Turner Sales Chicago
7698 Blake Sales Chicago
7369 Smith Research Dallas
7902 Ford Research Dallas
7876 Adams Research Dallas
7566 Jones Research Dallas
7788 Scott Research Dallas
7782 Clark Accounting New York
7839 King Accounting New York
7934 Miller Accounting New York
SQL>
| Attachment | Size |
|---|---|
| sql_implicit.sql_.txt | 84 bytes |
- sql_command's blog
- Login or register to post comments
- 365 reads
- Email this page












