Oracle实现判断功能三种方式总结

Oracle实现判断功能三种方式总结

1、case … when … then...else...end

select 
  case when t.字段名= '1' then '要设置的名字1'   when t.字段名 = '2' then '要设置的名字2'   else '要设置的名字3' end from 表名 t;

2、decode(条件,值1,返回值1,值2,返回值2,…值n,返回值n,缺省值)

select decode(t.content,'1','要设置的名字1','2','要设置的名字2','要设置的名字3') satis from 表名 t;

3、if … then … elseif... then...else...end if

if con = '1' then
   '要设置的名字1'
elsif con = '2' then
   '要设置的名字2'
else
   '要设置的名字3'
end if;
原文地址:https://www.cnblogs.com/Michelle20180227/p/15040441.html