2012-02-28 3 views
4

아래는 제 질문입니다. 이게 맞습니까?사용 방법 Case 문 내부의 조건?

SQL> select case when value in (1000) then null 
2 when user in ('ABC') then user 
3 when area in ('DENVER') then 
4 if value = 2000 then 'Service1' 
5 else value = 3000 then 'Service2' 
6 end if 
7 else null 
8 end as num_code from service_usoc_ref; 
if prin = 2000 then 'Omaha' 
* 
ERROR at line 4: 
ORA-00905: missing keyword 

도와주세요.

+0

사용 디코드 문을 – Maddy

답변

6

당신에게 도움이 될 수 :

select case 
    when value in (1000) then null 
    when user in ('ABC') then user 
    when area in ('DENVER') then 
    case when value = 2000 then 'Service1' 
     when value = 3000 then 'Service2' 
    end 
    else null 
    end as num_code 
from service_usoc_ref; 
3

이 (@madhu가 제안) 당신은 디코딩을 다른 사건을 넣어 사용하거나 할 수 있습니다

select case when value in (1000) then null 
         when user in ('ABC') then user 
         when area in ('DENVER') then 
decode(value, 2000 , 'Service1',3000 , 'Service2', NULL) num_code 
from service_usoc_ref;