语法
decode(条件,值1,返回值1,值2,返回值2,...值n,返回值n,缺省值)
select * from reglike; select decode(substr(name,1,3),'aaa','yes','no') decode from reglike;
![](https://images2017.cnblogs.com/blog/890017/201711/890017-20171107163911997-453052665.png)
![](https://images2017.cnblogs.com/blog/890017/201711/890017-20171107163913278-1690607653.png)
语法
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;
![](https://images2017.cnblogs.com/blog/890017/201711/890017-20171107163911997-453052665.png)
![](https://images2017.cnblogs.com/blog/890017/201711/890017-20171107163914013-1917527617.png)