`
kidiaoer
  • 浏览: 805818 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论

oracle条件查询:case和decode使用实例

阅读更多
oracle条件查询:case和decode使用实例
分别用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
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics