Oracle SQL(1) 함수
단일행 함수
- select, where, order by, update set 절에 사용 가능
- 함수의 인자로 상수, 변수, 표현식, 함수 사용 가능
📖 단일행 함수(문자)
lower()
upper()
substr()
length()
ltrim(), rtrim(), trim()
ascii()
truncate()
replace()
📖 단일행 함수(숫자)
abs()
mod()
round()
trunc()
sign()
chr()
ceil()
floor()
power()
exp()
log()
ln()
cos()
tan()
📖 단일행 함수(날짜)
sysdate #현재 날짜 출력
months_between() # 두 날짜 사이의 개월 수를 출력
add_months(a, b) # a 날짜부터 b개월 후 날짜 출력
next_day('2023/9/9', '금') #23/09/15가 출력된다. 해당 날짜 이후의 돌아오는 금요일 출력
last_day() #해당 날짜가 속할 달의 마지막 날을 출력
round(to_date(..), 'MONTH') #개월 단위로 날짜 반올림, 두 번째 인자 생략 시
#오후 12시를 기준으로 반올림한 날짜 출력
trunc()
보통 날짜 함수는 비 표준이다.
📖 단일행 함수(변환)
cast()
to_char()
to_date()
to_number()
📖 단일행 함수(etc)
nvl() #null값인 경우 지정한 다른 값으로 계산
decode()
nullif()
coalesce()
다중행 함수
avg()
sum()
max()
min()
count()
댓글남기기