본문 바로가기
DB/Mssql

oracle decode같이 사용하는 mssql case when then 문

by 새로운 도전을 위한 한걸음 2015. 5. 10.

oracle decode같이 사용하는 mssql case when then 문

 

/*** 오라클의  하나하나 주는 경우 .. else if ***/

select CASE b_no
 WHEN '1' THEN 'aaaaaaaaa'
 WHEN '2' THEN 'bbbbbbbbb'

when '3'  then '4444444'

 END

 from board

 

/***뭐가 아니면 할대 사용하는것 else  ***/
select CASE
 WHEN b_no = '1' THEN 'aaaaaaaaaaa'
 WHEN b_no  <> '2' THEN '222222222222'

 END

from board