decode函数

1、decode(value,if1,then1,if2,then2,if3,then3,...,else)

select DECODE(3,1,'case1',2,'case2',3,'case3',4,'case4',5,'case5',null) as testDecode from dual;

--结果:case3

2、decode 嵌套

select  decode(sum(total13),0,0,decode(sign((round(sum(b1)/sum(total13)*100)-100)),-1,round(sum(b1)/sum(total13)*100),100)) as b1 from dual;

原文地址:https://www.cnblogs.com/hm1990hpu/p/8872301.html