decode与case when

语法
decode(条件,值1,返回值1,值2,返回值2,...值n,返回值n,缺省值)
select * from reglike;
select decode(substr(name,1,3),'aaa','yes','no') decode from reglike;
 
 
语法
case when 条件1 then 值1 when 条件2 then 值2 ... when 条件n then 值n else 缺省值 end
select * from reglike;
select case when substr(name,1,3)='aaa' then 'yes' else 'no' end case from reglike; 
posted @ 2017-11-07 16:39  tongyongliang  阅读(311)  评论(0编辑  收藏  举报