如何在Case语句中使用If条件?

Sam*_*rai 5 oracle if-statement 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
Run Code Online (Sandbox Code Playgroud)

请帮我.

A.B*_*ade 9

你可以放另一个案例或使用解码(如@madhu建议):

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;
Run Code Online (Sandbox Code Playgroud)