[Oracle] NVL, NVL2, NULLIF, DECODE, COALESCE, CASE WHEN
NVL(칼럼, 변환 수) - NULL을 다른값으로 치환 select ename, sal, comm, NVL(comm, 1) , sal + NVL(comm, 0) from emp; NVL2(칼럼, 변환 값1, 변환 값2) 칼럼이 NULL이 아닌 경우에는 변환값1, NULL인 경우 변환값2 변환값1, 변환값 2는 데이터 입이 동일해야 함 select ename, comm, NVL2(comm, comm+700, 100) from emp; select player_name, nation, NVL2(nation, nation, '한국'), NVL2(nation, nation||'인', '한국인') from player; NULLIF(칼럼, 비교 값) - 비교 값 또는, NULL 반환 칼럼 값 == 비교 값 이면 ..
2023. 6. 20.
[Oracle/오라클] ROLLUP 소계 / 총계 표현하기
SELECT * FROM TB_POINT; SELECT NVL(CUSTOMER_CD,'총합') AS customer_cd, TO_CHAR(SUM(POINT),'999,999') AS 포인트합 FROM TB_POINT GROUP BY ROLLUP(CUSTOMER_CD) ORDER BY customer_cd; SELECT NVL(CUSTOMER_CD, '소계') 고객번호, TO_CHAR(SUM(POINT), '999,999') 포인트합, COUNT(*) 인원 FROM TB_POINT GROUP BY ROLLUP(CUSTOMER_CD); SELECT NVL(SALES_DT, '총합') AS SALES_DT, CASE WHEN SALES_DT IS NOT NULL AND PRODUCT_NM IS NULL THE..
2021. 7. 16.