1、语法:
CASE expression
WHEN expression_1 THEN result_1
WHEN expression_2 THEN result_2
...
[ELSE default_result]
END
2、举例:
select e.first_name,
e.last_name,
case e.job_id
when 'AD_PRES' then 'President'
when 'AD_VP' then 'vice president'
when 'IT_PROG' then 'Programer'
else 'Other job'
end as "JOB DESCRIPTION"
from employees e
3、结果:
1 William Gietz Other job
2 Shelley Higgins Other job
3 Jennifer Whalen Other job
4 Steven King President
5 Neena Kochhar vice president
6 Lex De Haan vice president
7 Daniel Faviet Other job
8 John Chen Other job
9 Ismael Sciarra Other job
10 Jose Manuel Urman Other job