본문 바로가기
SQL/Oracle

oracle case when 사용법

by 젤리씨 2023. 11. 14.
728x90

oracle case when 사용법 2가지

 

첫번째

SELECT column1, column2, column3, CASE WHEN column3 >= 500 THEN 1000
                                       WHEN column3 >= 300 THEN 500
                                       WHEN column3 >= 100 THEN 100
                                       ELSE 0 END AS nickname
    FROM tablename
    WHERE column2 = '1';

 

 

 

 

 

 

2번째

select 
column1, column2, CASE  column3
                        WHEN 'FFF'  THEN 'WHITE'
                        WHEN '000'  THEN 'BACK'
                        ELSE color_code
                  END column3
from tablename;

 

728x90

댓글