select last_name, department_id, salary,
case department_id when 10 then 1.10*salary
when 20 then 1.15*salary
when 30 then 1.20*salary
else salary
end "revised_salary "
from employees
CASE WHEN语句还可以用于统计 例:统计列印各科成绩,各分数段人数:课程ID,课程名称,[100-85],[85-70],[70-60],[ <60]
select b.cno,cname,
sum(case when score between 85 and 100 then 1 else 0 end) "[100-85]",
sum(case when score between 70 and 85 then 1 else 0 end) "[85-70]",
sum(case when score between 60 and 70 then 1 else 0 end) "[70-60]",
sum(case when score <60 then 1 else 0 end) "[<60]"
from course a,sc b where a.cno = b.cno group by b.cno,cname