oracle条件查询:case和decode使用实例
[code]
分别用case和decode函数列出员工所在的部门,deptno=10显示'部门10',
deptno=20显示'部门20'
deptno=30显示'部门30'
deptno=40显示'部门40'
否则为'其他部门'
select ename, case deptno
when 10 then '部门10'
when 20 then '部门20'
when 30 then '部门30'
when 40 then '部门40'
else '其他部门'
end 工资情况
from scott.emp

select ename,decode(deptno,10,'部门10',20,'部门20',30,'部门30',40,'部门40','其他部门') 工资情况 from scott.emp
[/code]