¡Ú. ÁýÇÕ Äõ¸®ÀÇ Á¾·ù
union : ÇÕÁýÇÕ union all : °øÅë¿ø¼Ò µÎ¹ø¾¿ ´Ù Æ÷ÇÔÇÑ ÇÕÁýÇÕ intersect : ±³ÁýÇÕ minus : Â÷ÁýÇÕ
¿¹>
a={1,3,5,7} b={1,2,3,4} a union b = {1,2,3,4,5,7} a union all b = {1,1,2,3,3,4,5,7} a intersect b = {1,3} a minus b = {2,5,7}
Union SQL> select * from sawon where sajob ='°úÀå' union select * from sawon where sajob in('°úÀå','´ë¸®');
union À» ±âÁØÀ¸·Î Á¿ìÀÇ ¼±Åñ¸¹®À» ¸ðµÎ ÇÕÇÑÁ¶°Ç¹®
(´Ü, Áߺ¹µÇ´Â Çʵ尡 ÀÖ´Â °æ¿ìÀÇ ·¹ÄÚµå´Â »)
ÇÕÁýÇÕ SQL> select * from sawon where sajob ='°úÀå' union all select * from sawon where sajob in('°úÀå','´ë¸®');
union all À» ±âÁØÀ¸·Î Á¿ìÀÇ ¼±Åñ¸¹®À» ¸ðµÎ ÇÕÇÑ Á¶°Ç¹®Àε¥, À§ÀÇ union ¸¸ ¾´°æ¿ì¿Í´Â ´Þ¸® Áߺ¹µÇ´Â Çʵ尡 Àִ°æ¿ì¿¡µµ ¸ðµç ·¹Å©µå¸¦ ºÒ·¯¿È
±³ÁýÇÕ SQL> select * from sawon where sajob ='°úÀå' intersect select * from sawon where sajob in('°úÀå','´ë¸®');
intersect ¸¦ ±âÁØÀ¸·Î Á¿ìÀÇ ¼±Åù®Áß Áߺ¹µÇ´Â ÀڷḸ ºÒ·¯¿È
Â÷ÁýÇÕ SQL> select * from sawon where sajob ='°úÀå' minus select * from sawon where sajob in('°úÀå','´ë¸®');
minus ¸¦ ±âÁØÀ¸·Î Áߺ¹µÇ´Â ÀڷḦ »« ³ª¸ÓÁö ÀڷḸ ºÒ·¯¿È
¡Ú. ¹®Àڿó¸®ÇÔ¼ö
1 . CONCAT( column1|expression1 ,column2|expression2 )
CONCAT('Good','String') --> GoodString : ||¿Í °°Àº ¿ªÇÒÀ» ÇÑ´Ù.
SELECT CONCAT(pj_cd, pj_nm) FROM tpd01m;
2 . SUBSTR(column|expression, m [,n]) : m°ªÀÌ À½¼ö¸é ¹®ÀÚ°ªÀÇ ³¡ºÎÅÍ..)
SUBSTR('String',1,3) --> Str : 1¹ø°ºÎÅÍ 3°³ÀÇ ¹®ÀÚ¸¦ ¸®ÅÏÇÑ´Ù.
SELECT SUBSTR(pj_cd, 3, 3) FROMtpd01m;
3. INITCAP( column|expression )
INITCAP('string') --> String : ù±ÛÀÚ¸¸ ´ë¹®ÀÚÀÌ°í ³ª¸ÓÁö±ÛÀÚ´Â ¼Ò¹®ÀÚ·Î º¯È¯
SELECT INITCAP(pj_cd) FROM tpd01m;
4. SUBSTRB(column|expression, m [,n]) : m°ªÀÌ À½¼ö¸é ¹®ÀÚ°ªÀÇ ³¡ºÎÅÍ..)
SUBSTRB('String',1,3) --> Str : 1¹ø°ºÎÅÍ 3°³ÀÇ ¹®ÀÚ¸¦ ¸®ÅÏÇÑ´Ù
substr ±ÛÀÚ±âÁØ substrb ¹ÙÀÌÆ®±âÁØ ¿¹) col="¿ì¸®³ª¶ó"
substr(col,1,2) --> ¿ì¸® substrb(col,1,2) --> ¿ì
SELECT SUBSTRB(pj_cd, -3, 3) FROM tpd01m;
5.UPPER( column|expression )
UPPER('String') --> STRING : ´ë¹®ÀÚ·Î º¯È¯
SELECT UPPER(pj_cd) FROM tpd01m;
6.LOWER( column|expression )
LOWER('String') --> string : ¼Ò¹®ÀÚ·Î º¯È¯
SELECT LOWER(pj_cd) FROM tpd01m;
7. LPAD( column|expression,n,'string' ) : n Àº Àüü ±æÀÌ
LPAD('String',10,'*') --> ****String
: 10ÀÚ¸®¼öÁß¿¡ ¸ðÀÚ¶õ ÀÚ¸®¼ö¸¦ '*'·Î ¿ÞÂÊ¿¡ ä¿î´Ù.(¹®ÀÚ,¼ýÀÚ °¡´É!!!)
SELECT LPAD(pj_cd, 20, '*') FROM tpd01m;
8. RPAD('String',10,'*') --> String****
: 10ÀÚ¸®¼öÁß¿¡ ¸ðÀÚ¶õ ÀÚ¸®¼ö¸¦ '*'·Î ¿À¸¥ÂÊ¿¡ ä¿î´Ù.(¹®ÀÚ,¼ýÀÚ °¡´É!!!)
SELECT RPAD(pj_cd, 20, '&') FROM tpd01m;
9. LENGTH( column|expression )
LENGTH('String') --> 6 : ¹®ÀÚ¿ÀÇ ±æÀ̸¦ ¸®ÅÏÇÑ´Ù.
SELECT LENGTH(pj_cd) from tpd01m;
10. REPLACE(column | 0 , 'r') L01102 => Lr11r2
SELECT REPLACE(pj_cd, 0, '^^') FROM tpd01m; --´ë¼Ò¹®ÀÚ ±¸ºÐ
11. INSTR( column|expression )
INSTR('String','r') --> 3 : ¹®ÀÚ¿¿¡ 'r'ÀÌ ¸î¹ø° À§Ä¡ÇÏ°í ÀÖ³ª¸¦ (¼ýÀÚ)¸®ÅÏÇÑ´Ù.
SELECT INSTR(pj_cd, 0) FROM tpd01m;
12 . LTRIM(' String') --> 'String' : ¹®ÀÚ¿ÀÇ ¿ÞÂÊ °ø¹éÀ» ¹ö¸°´Ù.
13. RTRIM('String ') --> 'String' : ¹®ÀÚ·ÉÀÇ ¿À¸¥ÂÊ °ø¹éÀ» ¹ö¸°´Ù.
* TRIM(leading/tailing/both, trim_character FROM trim_source )
TRIM( 'S' FROM 'SSMITH') --> MITH
¡Ú. ¼ýÀÚ Ã³¸®ÇÔ¼ö
1. ROUND(45.926, 2) --> 45.93 : ¼Ò¼öÁ¡ µÎÀÚ¸®¼ö±îÁö º¸¿©ÁÖ¸é¼ ¹Ý¿Ã¸²ÇÑ´Ù.
2. TRUNC(45.926, 2) --> 45.92 : ¼Ò¼öÁ¡ µÎÀÚ¸®±îÁö¸¸ º¸¿©ÁÖ°í ³ª¸ÓÁö´Â ¹ö¸°´Ù.
3. MOD(1600,300) --> 100 : 1600À» 300À¸·Î ³ª´©°í ³ª¸ÓÁö¸¦ ¸®ÅÏÇÑ´Ù.
* ROUND¿¹Á¦(WHOLE NUMBER:Á¤¼ö)
SELECT ROUND(45.923,2), ROUND(45.923,0), ROUND(45.923,-1) FROM DUAL
==> 45.92 46 50
* TRUNC¿¹Á¦
SELECT TRUNC(45.923,2), TRUNC(45.923), TRUNC(45.923,-1) FROM DUAL
==> 45.92 45(nÀÌ »ý·«µÈ¸é ÀÏÀÇ ÀÚ¸®±îÁö ³²±â°í ¹ö¸°´Ù.) 40
* SYSTEM ³¯Â¥¸¦ °®°í ¿À´Â ¹æ¹ý.
SELECT sysdate FROM dual
¡Ú. Date
Date °è»ê( ³¯Â¥¸¦ ¼ýÀÚ·Î ÀúÀå) date + number : date¿¡ number¸¸Å ÈÄÀÇ ³¯ÀÚ¸¦ º¸¿©ÁØ´Ù.
date - number : date¿¡ number¸¸Å ÀüÀÇ ³¯ÀÚ¸¦ º¸¿©ÁØ´Ù.
date1 - date2 : date1¿¡¼ date2 ±îÁöÀÇ ÃÑ Àϼö¸¦ º¸¿©ÁØ´Ù.( date1+date2´Â X )
date1 + ¼ýÀÚ/24 : date1¿¡¼ ½Ã°£À» ´õÇØ ³¯Â¥¸¦ º¸¿©ÁØ´Ù.
Date Functions
MONTHS_BETWEEN('01-SEP-95','11-JAN-94') --> 19.6774194
; µÎ³¯Â¥ »çÀÌÀÇ ´Þ¼ö¸¦ º¸¿©ÁØ´Ù.
ADD_MONTHS('11-JAN-94', 6) --> 11-JUL-94
; ³¯Â¥¿¡ 6°³¿ùÀ» ´õÇÑ ³¯ÀÚ¸¦ º¸¿©ÁØ´Ù.
NEXT_DAY('01-SEP-95','FRIDAY') --> '08-SEP-95'
; ÇØ´çÀÏ ´ÙÀ½¿¡ ¿À´Â FRIDAYÀÇ ÀÏÀÚ¸¦ º¸¿©ÁØ´Ù.
('SUNDAY'´Â 1, 'MONDAY'´Â 2...ÀÌ·±½ÄÀ¸·Î ¼ýÀÚ¸¦ ½áÁ൵ µÈ´Ù.)
LAST_DAY('01-SEP-95') --> '30-SEP-95'
; ÇØ´ç¿ùÀÇ ¸¶Áö¸·³¯ÀÚ¸¦ º¸¿©ÁØ´Ù.
ROUND('25-JUL-95','MONTH')--> 01-AUG-95
ROUND('25-JUL-95','YEAR')--> 01-JAN-96
TRUNC('25-JUL-95','MONTH') --> 01-JUL-95
TRUNC('25-JUL-95','YEAR') --> 01-JAN-95
¡Ú. Conversion Functions
nlsparams : ½ÊÁø¼ö, ±×·ì±¸ºÐÀÚ, Áö¿ª ÅëÈ ±âÈ£, ±¹Á¦ ÅëÈ ±âÈ£
TO_CHAR(date,['format'],[nlsparams]) : date¸¦ format¿¡ ¸Â°Ô ¹®ÀÚ¿·Î º¯È¯ÇÑ´Ù.
- Date Format Elements
YYYY --> 1999 (³âÃâ·Â) , YEAR --> nineteen ninety-nine (³âÃâ·Â)
MM --> 12 (¿ùÃâ·Â) , MONTH --> DECEMBER (¿ùÃâ·Â), MON --> DEC
D --> ¿äÀÏÀ» ¼ýÀÚ·Î ¸®ÅÏÇÑ´Ù.(ÀÏ¿äÀÏÀº 1, ¿ù¿äÀÏÀº 2...)
DD --> 07 (´ÞÀÇ ÀÏÃâ·Â)
DDD --> 200 (¿¬ÀÇ ÀÏÃâ·Â)±× ÇØÀÇ ÃÑ ¸î ÀÏ°Àΰ¡¸¦ ¸®ÅÏÇÑ´Ù.
DAY --> MONDAY (¿äÀÏÃâ·Â) DY-->MON
CC --> 20 (¸î ¼¼±âÀÎÁö¸¦ º¸¿©ÁØ´Ù.)
WW --> ±× ÇØÀÇ ¸î ¹ø° ÁÖÀΰ¡¸¦ ¸®ÅÏÇÑ´Ù.
W --> ±× ´ÞÀÇ ¸î ¹ø° ÁÖÀΰ¡¸¦ ¸®ÅÏÇÑ´Ù.
* ElementµéÀ» ¼Ò¹®ÀÚ·Î ¾²¸é ¼Ò¹®ÀÚ·Î ³ª¿À°í ´ë¹®ÀÚ·Î ¾²¸é ´ë¹®ÀÚ·Î Ãâ·ÂµÈ´Ù.
HH or HH12 or HH24 / MI(0-59ºÐ) / SS(0-59ÃÊ)
* ¹®ÀÚ¿Àº " " ¹¾î Ãß°¡ÇÑ´Ù DD " of " MONTH --> 12 of DECEMBER
*¼ýÀÚ Á¢¹Ì¾î´Â ¼ýÀÚ¸¦ ¹®ÀڷΠǥ±â. TH(4->4TH)/ SP(4->FOUR)/ SPTH or THSP(4->FOURTH)
ddspth : 14-> fothteenth
* / . , : ±¸µÎÁ¡Àº °á°ú¿¡ ±×´ë·Î Ãâ·ÂÇÑ´Ù. * °ø¹é, ¼±ÇàÁ¦·Î¸¦ Á¦°ÅÇÏ´Â fm¿ä¼Ò°¡ ÀÖ´Ù.
TO_CHAR(number,'format',[nlsparams]) : number¸¦ format¿¡ ¸Â°Ô ¹®ÀÚ¿·Î º¯È¯ÇÑ´Ù.
- Number Format Elements
9 : 999,999 --> 1,234 $: ºÎµ¿ ´Þ·¯ ±âÈ£ $99999 -> $1234
0 : 099999 --> 001234 99.999EEEE -> 1.234E+03 B: 0°ªÀ» °ø¹éÀ¸·Î
L : L99,999 --> FF1,234 (NLS_CURRENCY¿¡ ¼³Á¤µÇ¾îÀÖ´Â °ªÀÌ L·Î º¸¿©Áø´Ù.)
TO_NUMBER(char,['format'],[nlsparams]) : ¼ýÀÚÇüÅÂÀÇ ¹®ÀÚ¿À» ¼ýÀÚ·Î º¯ÇÑÇÑ´Ù.
TO_DATE(char,['format'],[nlsparams]):³¯ÀÚÇüÅÂÀÇ ¹®ÀÚ¿À» format¿¡ ¸Â°Ô ³¯ÀÚÇü½ÄÀ¸·Î º¯È¯ ÇÑ´Ù.
¡Ú. NVL Funcion : °ªÀÌ nullÀÏ ¶§ ¼³Á¤°ªÀ» º¸¿©ÁØ´Ù.
NVL(number_column, 0) : nullÀÏ ¶§ 0À» º¸¿©ÁØ´Ù.
NVL(date_column, '01-JAN-95') : nullÀÏ ¶§ '01-JAN-95'¸¦ º¸¿©ÁØ´Ù.
NVL(character_column, 'Empty') : nullÀÏ ¶§ 'Empty'¸¦ º¸¿©ÁØ´Ù.
* column Type°ú Ç¥Çö½ÄÀÇ typeÀÌ ¹Ýµå½Ã ÀÏÄ¡ÇØ¾ß ÇÑ´Ù.
¡Ú. DECODE Function : CASE or IF-THEN-ELSE Çü½Ä°ú ºñ½ÁÇÏ´Ù.
*DECODE(col/expression, search1, result1 [,search2,result2,¡¦] [,default])
F1 (F2 (F3 (col,arg1),arg2),arg3)
-------------------------------------------------------------------------------------------------------
¿¹Á¦
-------------------------------------------------------------------------------------------------------
/** ÇÔ¼ö - Number Function **/
--¹«Á¶°Ç ¿Ã¸² SELECT CEIL(13.11) FROM DUAL; SELECT CEIL(13.001) FROM DUAL;
--³ª¸ÓÁö ±¸ÇÔ SELECT MOD(23, 5) FROM DUAL; SELECT MOD(57, 145) FROM DUAL;
-- Á¦°ö½Â SELECT POWER(3, 2), POWER(3, -2) FROM DUAL; SELECT POWER(2, 10) FROM DUAL;
--ÀÚ¸´¼ö ÁöÁ¤ SELECT ROUND(345.123, 0) FROM DUAL; SELECT ROUND(345.123, 2), ROUND(345.123, -1) FROM DUAL;
--ÁöÁ¤µÈ ÀÚ¸®±îÁö À߶󳻱â SELECT TRUNC(345.123, 1), TRUNC(345.123, 0), TRUNC(345.123, -1) FROM DUAL; SELECT TRUNC( 345.123 + 0.09, 1 ) FROM DUAL; SELECT TRUNC( 345.123 + 0.9, 0 ) FROM DUAL; SELECT TRUNC( 345.123 + 9, -1 ) FROM DUAL;
SELECT SIGN(5.989), SIGN(0), SIGN(-999.098) FROM DUAL;
/** ÇÔ¼ö - Character Function **/
--ƯÁ¤CharacterÀÇ ¾Æ½ºÅ°°ª ±¸Çϱâ SELECT CHR(65) "CHR", ASCII('A') "ASCII" FROM DUAL;
SELECT ASCII( CHR(65) ) FROM DUAL;
SELECT LOWER('My name is LKM') "LOWER", UPPER('My name is LKM') "UPPER" FROM DUAL;
SELECT LPAD('LKM', 10, '*') "LPAD", RPAD('LKM', 10, '*') "RPAD" FROM DUAL;
SELECT LPAD('1234567890', 20, '+') || RPAD('1234567890', 20, '^') "12345678901234567890" FROM DUAL;
SELECT LPAD('1,234,567', 30, ' ') "LPAD»ç¿ëÀ¸·Î 30ÀÚ¸® ¸ÂÃã", '1,234,567' "´Ü¼ø¹®ÀÚ »ç¿ë", 1234567 "´Ü¼ø¼ýÀÚ »ç¿ë" FROM DUAL;
SELECT LTRIM(' AAA ') "LTRIM", RTRIM(' AAA ') "RTRIM" FROM DUAL;
SELECT LTRIM( RTRIM( ' A A A ' ) ) "TRIM" FROM DUAL;
SELECT REPLACE('ORACLE', 'A', 'BBB') "REPLACE" FROM DUAL;
SELECT EMP_NAME, REPLACE(EMP_NAME, 'ÀÌ', '¹Ú') "ÀÌ->¹Ú" FROM PERSONNEL WHERE EMP_NAME LIKE 'ÀÌ%';
SELECT SUBSTR('ORACLE PROJECT', 1, 3) SUBSTR1, SUBSTR('ORACLE PROJECT', 4, 5) SUBSTR2, SUBSTR('ORACLE PROJECT', 10) SUBSTR3 FROM DUAL ;
SELECT SUBSTRB('ORACLE PROJECT', 1, 3) SUBSTRB1, SUBSTRB('ORACLE PROJECT', 4, 5) SUBSTRB2, SUBSTRB('ORACLE PROJECT', 10) SUBSTRB3 FROM DUAL ;
SELECT SUBSTR('¿À¶óŬ PROJECT', 1, 3) SUBSTR1, SUBSTR('¿À¶óŬ PROJECT', 4, 5) SUBSTR2, SUBSTR('¿À¶óŬ PROJECT', 10) SUBSTR3 FROM DUAL ;
SELECT SUBSTRB('¿À¶óŬ PROJECT', 1, 3) SUBSTRB1, SUBSTRB('¿À¶óŬ PROJECT', 4, 5) SUBSTRB2, SUBSTRB('¿À¶óŬ PROJECT', 10) SUBSTRB3 FROM DUAL ;
SELECT LENGTH ('ORACLE PROJECT') "LENGTH", LENGTHB('ORACLE PROJECT') "LENGTHB", FROM DUAL;
SELECT EMPNO, LENGTH (EMPNO), LENGTHB(EMPNO), EMP_NAME, LENGTH (EMP_NAME), LENGTHB(EMP_NAME) FROM PERSONNEL WHERE EMPNO > '98102';
SELECT HOBBY, LENGTH (HOBBY), LENGTHB(HOBBY) FROM PERSONNEL WHERE EMPNO > '98102';
SELECT INSTR ('ORACLE PROJECT', 'R', 1, 1) INSTR1, INSTR ('ORACLE PROJECT', 'R', 1, 2) INSTR2, INSTR ('ORACLE PROJECT', 'R', 1, 3) INSTR3 FROM DUAL;
SELECT INSTR ('CORPORATE FLOOR','OR', 3, 2) INSTR , INSTRB ('CORPORATE FLOOR','OR', 3, 2) INSTRB FROM DUAL;
SELECT HOBBY, INSTR (HOBBY, ')', 1, 1) INSTR, INSTRB (HOBBY, ')', 1, 1) INSTRB FROM PERSONNEL WHERE EMPNO > '98102';
/** ÇÔ¼ö - Date Function **/
SELECT SYSDATE FROM DUAL;
SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS') "SYSDATE" FROM DUAL;
SELECT LAST_DAY(SYSDATE) FROM DUAL;
SELECT TO_CHAR(LAST_DAY(SYSDATE), 'YYYY-MM-DD HH24:MI:SS') "LAST_DAY" FROM DUAL;
SELECT MONTHS_BETWEEN( '2002/01/13', '2002/05/13' ) "MONTHS_BETWEEN (-)", MONTHS_BETWEEN( '2002/01/13', '2001/11/13' ) "MONTHS_BETWEEN (+)" FROM DUAL ;
SELECT MONTHS_BETWEEN( '2002/01/13', '2002/01/30' ) "MONTHS_BETWEEN (-)", MONTHS_BETWEEN( '2002/01/13', '2002/01/01' ) "MONTHS_BETWEEN (+)" FROM DUAL ;
SELECT ADD_MONTHS(SYSDATE, 1) "ADD_MONTHS (+)", ADD_MONTHS(SYSDATE, -1) "ADD_MONTHS (-)" FROM DUAL ;
ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD'; SELECT ADD_MONTHS( '2002/02/28', 12 ) "1³âÈÄ", ADD_MONTHS( '2002/02/28', 24 ) "2³âÈÄ", ADD_MONTHS( '2002/02/28', 36 ) "3³âÈÄ" FROM DUAL ;
SELECT SYSDATE, NEXT_DAY(SYSDATE, 'ÀÏ¿äÀÏ') "NEXT_DAY 1", NEXT_DAY(SYSDATE, 1 ) "NEXT_DAY 2" FROM DUAL;
SELECT SYSDATE, NEXT_DAY(SYSDATE, '¼ö¿äÀÏ') "NEXT_DAY 1", NEXT_DAY(SYSDATE, 4 ) "NEXT_DAY 2" FROM DUAL;
/** ÇÔ¼ö - Conversion Function **/
SELECT TO_CHAR(1234567.891) "TO_CHAR1", TO_CHAR(1234567.891, '999') "TO_CHAR2", TO_CHAR(1234567.891, '9,999,999') "TO_CHAR3", TO_CHAR(1234567.891, '0.0000') "TO_CHAR5", TO_CHAR(1234567.891, '9,999,999.0000') "TO_CHAR6", TO_CHAR(123, '9,999.00') "TO_CHAR7", TO_CHAR(123, '9,999.99') "TO_CHAR8" FROM DUAL ;
SELECT TO_CHAR(1234567.891, '9G999G999') "TO_CHAR3", TO_CHAR(1234567.891, '0D0000') "TO_CHAR5", TO_CHAR(1234567.891, '9G999G999D0000') "TO_CHAR6", TO_CHAR(123, '9G999D00') "TO_CHAR7", TO_CHAR(123, '9G999D99') "TO_CHAR8" FROM DUAL ;
SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD') "TO_CHAR1", TO_CHAR(SYSDATE, 'YYYY/MM') "TO_CHAR2", TO_CHAR(SYSDATE, 'YYYY') "TO_CHAR3", TO_CHAR(SYSDATE, 'DD') "TO_CHAR4", TO_CHAR(SYSDATE, 'DAY') "TO_CHAR5", TO_CHAR(SYSDATE, 'YYYY/MM/DD HH24:MI:SS') "TO_CHAR6", TO_CHAR(TO_DATE('20020101','YYYYMMDD'), 'YYYY-MM-DD') "TO_CHAR7", TO_CHAR(TO_DATE('20020101','YYYYMMDD'), 'YYYYMMDD HHMISS') "TO_CHAR8" FROM DUAL ;
SELECT TO_NUMBER('123456.9') "TO_NUMBER1", TO_NUMBER('1234567') "TO_NUMBER2" FROM DUAL ;
SELECT TO_NUMBER('123,456.9', '999,999.9') "TO_NUMBER1", TO_NUMBER('1,234,567', '9G999G999') "TO_NUMBER2" FROM DUAL ;
ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'; SELECT TO_DATE('20020824') "TO_DATE1", TO_DATE('2002-08-24') "TO_DATE2", TO_DATE('200208') "TO_DATE3" FROM DUAL ;
SELECT TO_DATE('20020824', 'YYYYMMDD') "TO_DATE1", TO_DATE('2002-08-24', 'YYYY-MM-DD') "TO_DATE2", TO_DATE('200208', 'YYYYMM') "TO_DATE3" FROM DUAL ;
SELECT TO_DATE('2002/08/24 08:14:06', 'YYYY/MM/DD HH24:MI:SS') "TO_DATE1", TO_DATE('2002/08/24 08:14:06 ¿ÀÈÄ', 'YYYY/MM/DD HH:MI:SS AM') "TO_DATE2" FROM DUAL ;
/** ÇÔ¼ö - Group Function **/
SELECT AVG(HEIGHT), AVG(WEIGHT) FROM PERSONNEL;
SELECT MAX(EMPNO), MAX(EMP_NAME), MIN(EMPNO), MIN(EMP_NAME) FROM PERSONNEL;
SELECT MAX(HEIGHT), MIN(HEIGHT) FROM PERSONNEL;
SELECT SUM(WEIGHT) FROM PERSONNEL;
SELECT COUNT(*), COUNT(EMPNO), COUNT(JIKCH_CODE) FROM PERSONNEL;
/** ÇÔ¼ö - ETC **/
SELECT EMPNO, EMP_NAME, HOBBY Ãë¹Ì, WELL Ư±â FROM PERSONNEL WHERE EMPNO BETWEEN '98001' AND '98005';
SELECT EMPNO, EMP_NAME, HOBBY Ãë¹Ì, NVL(WELL, '(¾ø´Ù)') Ư±â FROM PERSONNEL WHERE EMPNO BETWEEN '98001' AND '98005';
SELECT DECODE( '³ª', '³ª', '¸Â´Ù', '¾Æ´Ï´Ù' ) "³ª°¡ ³ª¸é ¸Â´Ù, ¾Æ´Ï¸é ¾Æ´Ï´Ù" FROM DUAL ;
SELECT DECODE( '³ª', '´ë¸í', '¾Æ´Ï´Ù', '³Ê' , '¾Æ´Ï´Ù', '±×' , '¾Æ´Ï´Ù', '³ª' , '¸Â´Ù', '¸ð¸£°Ú´Ù' ) FROM DUAL ;
SELECT EMPNO, EMP_NAME, DECODE(HT_CODE, '1', 'ÇöÀç¿ø', '2', 'ÈÞÁ÷', 'Åð»ç') HT_CODE FROM PERSONNEL WHERE EMPNO BETWEEN '98071' AND '98080';
SELECT GREATEST (132, 33, 45, 90, 60.77) GREATEST, LEAST (132, 33, 45, 90, 60.77) LEAST FROM DUAL;
SELECT GREATEST ('ÀÌ°ø¸í', 'ÀÌ´ë¸í', 'ÃÖ¼ö¹Ì') GREATEST, LEAST ('ÀÌ°ø¸í', 'ÀÌ´ë¸í', 'ÃÖ¼ö¹Ì') LEAST FROM DUAL;
SELECT USERENV('LANGUAGE') "LANGUAGE", USERENV('TERMINAL') "TERMINAL", USERENV('SESSIONID') "SESSIONID" FROM DUAL; SELECT UID, USER FROM DUAL;
|