星生

导航

Oracle case when

直接看例子:

select
  (case sex when '1' then '男'
       when '2' then '女'
       else '未知' end)
  as sex
from person

等价于 <==>

select
  (case
    when sex='1' then '男'
    when sex='2' then '女'
    else '未知' end)
  as sex
from person

等价于 <==>

select decode(sex,'1','男','2','女','未知') as sex from person

 

posted on 2015-09-06 16:14  Q星ZX  阅读(546)  评论(0编辑  收藏  举报