nvl, nvl2, decode, case ~ when ~ then
nvl(column, 대체값) - column이 null이면 대체값 적용 - column이 null이 아니면, column의 원래 값이 나옵니다. nvl2 (column, 대체값1, 대체값2) - 대체값이 같은 데이터 타입이여야한다. 앞의 대체값의 데이터타입을 따른다. (자동 형변환 됨) - column이 null이면 대체값2 적용 - column이 null이 아니면, 대체값 1 적용 주의* 대체값은 column의 datat type과 같아야한다. 예시) select ename, job, sal, comm from emp; select ename, job, sal, nvl(comm, 0) from emp; --select ename, job, sal, nvl(comm, sysdate) from emp; ..
to_date, months_between, add_months, next_day, last_day, 날짜 반올림과 자르기
to_date : 문자를 날짜로 변경 예시) select to_date('20220512') from dual; months_between : 두 날짜 간의 기간을 월로 계산 예시) select sysdate, to_date('20220927'), months_between(to_date('20220927'), sysdate) from dual; --4.47 --4.5달 add_months : 기준 날짜에 개월 수를 추가한 날짜를 계산 next_day : 돌아오는 다음 요일 예시) 일1 월2 화3 수4 목5 금6 토7 select sysdate, ' 다음 일요일', next_day(sysdate, 1) from dual; select sysdate, ' 다음 월요일', next_day(sysdate, 2..
number type, ceil, floor, round, mod, trunc
Oracle data type중 number type - number(7,2) : 숫자의 총 길이는 7 + 소수점 이하가 2 : 5자리 정수 + 2자리 소수. - number(7,2) : double - number(4,0) : 숫자의 총 길이는 4 + 소수점 이하가 0 : 4 자리 정수. - number(4,0) : int 오라클의 기본 함수 (문자, 수, 날짜) 오라클의 함수는 ( )를 넣는다 sysdate : 컴퓨터 시스템의 날짜 ceil : 올림 floor : 내림 round : 반올림 mod : 나머지 trunc : 소수점 이하의 자리 수를 자른다 예시) select sysdate from dual; -- 컴퓨터 시스템의 날짜 select ceil(0.9) from dual; -- 올림 : 1 ..