프로그램/database

MSSQL Oracle Query 변환 참고

mulderu 2010. 5. 19. 16:34
아래의 사이트 참조



쿼리 오라클9i MS-SQL2000
값 대체 DECODE 
ex) DECODE(컬럼명, 'A', 'OK', 'B', 'NO', 컬럼명)
CASE WHEN (오라클도 있음) 
ex) CASE WHEN 컬럼명 = 'A' THEN 'OK' WHEN 컬럼명 = 'B' THEN 'NO' ELSE 컬럼명 END
문자열 자르기 SUBSTR 
ex) SUBSTR('ANSDDD', 1, 2) = 'AN'
SUBSTRING 
ex) SUBSTRING('ANSDDD', 1,2) = 'AN'
시스템시간 SYSDATE GETDATE()
널값제어 NVL 
ex) NVL(컬럼명,0) => 컬럼값이 널이면 0으로 대체
isNULL 
ex) isNULL(컬럼명,0) => 컬럼값이 널이면 0으로 대체
형변환 TO_CHAR,TO_NUMBER 
ex) TO_CHAR(컬럼명) => 문자열 형태로 변환
CONVERT 
ex) CONVERT(VARCHAR,컬럼명) => 문자열 형태로 변환





Math Functions
FunctionOracleSQL Server
Absolute value ABS ABS
Arc cosine ACOS ACOS
Arc sine ASIN ASIN
Arc tangent of n ATAN ATAN
Arc tangent of n and m ATAN2 ATN2
Smallest integer >= value CEIL CEILING
Cosine COS COS
Hyperbolic cosine COSH COT
Exponential value EXP EXP
Round down to nearest integer FLOOR FLOOR
Natural logarithm LN LOG
Logarithm, any base LOG(N) N/A
Logarithm, base 10 LOG(10) LOG10
Modulus (remainder) MOD USE MODULO (%) OPERATOR
Power POWER POWER
Random number N/A RAND
Round ROUND ROUND
Sign of number SIGN SIGN
Sine SIN SIN
Hyperbolic sine SINH N/A
Square root SQRT SQRT
Tangent TAN TAN
Hyperbolic tangent TANH N/A
Truncate TRUNC N/A
Highest number in list GREATEST N/A
Lowest number in list LEAST N/A
Convert number if NULL NVL ISNULL
Standard deviation STDDEV STDEV
Variance VARIANCE VAR
String Functions
FunctionOracleSQL Server
Convert character to ASCII ASCII ASCII
String concatenate CONCAT (expression + expression)
Convert ASCII to character CHR CHAR
Return starting point of character in character string (from left) INSTR CHARINDEX
Convert characters to lowercase LOWER LOWER
Convert characters to uppercase UPPER UPPER
Pad left side of character string LPAD N/A
Remove leading blank spaces LTRIM LTRIM
Remove trailing blank spaces RTRIM RTRIM
Starting point of pattern in character string INSTR PATINDEX
Repeat character string multiple times RPAD REPLICATE
Phonetic representation of character string SOUNDEX SOUNDEX
String of repeated spaces RPAD SPACE
Character data converted from numeric data TO_CHAR STR
Substring SUBSTR SUBSTRING
Replace characters REPLACE STUFF
Capitalize first letter of each word in string INITCAP N/A
Translate character string TRANSLATE N/A
Length of character string LENGTH DATALENGTH or LEN
Greatest character string in list GREATEST N/A
Least character string in list LEAST N/A
Convert string if NULL NVL ISNULL
Date Functions
FunctionOracleSQL Server
Date addition (use +) DATEADD
Date subtraction (use -) DATEDIFF
Last day of month LAST_DAY N/A
Time zone conversion NEW_TIME N/A
First weekday after date NEXT_DAY N/A
Convert date to string TO_CHAR DATENAME
Convert date to number TO_NUMBER(TO_CHAR()) DATEPART
Convert string to date TO_DATE CAST
Get current date and time SYSDATE GETDATE()