-- 기본적인 ORACLE CASE 문법
CASE
WHEN [조건문1] THEN
( [조회문1] )
WHEN [조건문2] THEN
( [조회문2] )
WHEN [조건문3] THEN
( [조회문3] )
END
-- 사용법 예시
-- EX)
SELECT
A.SAMPLE_ID
, CASE
WHEN A.SAMPLE_DIV_CD = '001' THEN
( SELECT B.SAMPLE_CD FROM SMAPLE_CD_TABLE B WHERE B.SAMPLE_DIV_CD = '001' )
WHEN A.SAMPLE_DIV_CD = '002' THEN
( SELECT B.SAMPLE_CD FROM SMAPLE_CD_TABLE B WHERE B.SAMPLE_DIV_CD = '002' )
WHEN A.SAMPLE_DIV_CD = '003' THEN
( SELECT B.SAMPLE_CD FROM SMAPLE_CD_TABLE B WHERE B.SAMPLE_DIV_CD = '003' )
END AS SAMPLE_CD
FROM
SAMPLE_TABLE_1 A