oracle中case when then及decode用法

来源:互联网 发布:24小时私人网络上借钱 编辑:程序博客网 时间:2024/05/16 15:45

decode函数:
decode(条件,值1,返回值1,值2,返回值2,…….,缺省值)
一个Update语句:把表中某个字段的值进行更改,这条语句是把值为“1”的都改成“8”,“0”改成“9”

update tablename set 字段名= decode(字段名,1,8,0,9)  where 字段名 in (1, 0);

case…when…then:
– 写法一:
case(条件)
when 值1 then 返回值1
when 值2 then 返回值2
else 缺省值
– 写法二:
case when 条件1 then 返回值1
when 条件2 then 返回值2
else 缺省值
end;

1 0
原创粉丝点击