SQL>
SQL> CREATE TABLE DEPT (DEPTNO NUMBER(2),DNAME VARCHAR2(14),LOC VARCHAR2(13) );
Table created.
SQL>
SQL> INSERT INTO DEPT VALUES (10, 'ACCOUNTING', 'NEW YORK');
1 row created.
SQL> INSERT INTO DEPT VALUES (20, 'RESEARCH', 'DALLAS');
1 row created.
SQL> INSERT INTO DEPT VALUES (30, 'SALES', 'CHICAGO');
1 row created.
SQL> INSERT INTO DEPT VALUES (40, 'OPERATIONS', 'BOSTON');
1 row created.
SQL>
SQL> select * from dept;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
4 rows selected.
SQL>
SQL> select dname, decode( loc, 'BOSTON', 'Red Sox fans',
2 'CHICAGO', 'White Sox fans',
3 'DALLAS', 'Astros fans',
4 'NEW YORK', 'Mets fans' ) "Baseball Team"
5 from dept;
DNAME Baseball Team
-------------- --------------
ACCOUNTING Mets fans
RESEARCH Astros fans
SALES White Sox fans
OPERATIONS Red Sox fans
4 rows selected.
SQL>
SQL> drop table dept;
Table dropped.
SQL> --
|