[MS-SQL] CASE WHEN 사용법

순수한 사용법이라 첨언 할 부분이 없다.

기본 구조는 이러하다

case when 조건1 then 결과1
when 조건2 then 결과2
when 조건3 then 결과3
else 결과n

 

■ 예제

select 
 case 직급 when '사원' then 1 
 when '주임' then 2
 when '대리' then 3
 when '과장' then 4
 else 5
 end 직급코드
from 직원테이블

 

Post Author: 김 키티

답글 남기기

이메일 주소를 발행하지 않을 것입니다. 필수 항목은 *(으)로 표시합니다