Oracle decode函数用法

decode(condition,1,a,2,b,3,c,d)
condition是对某字段判断的条件
判断的结果是1,那么decode返回a,以此类推,最后所有结果都不在其中则返回d
结果1,a;2,b;3,c等可以多个

比如:select decode(column1,null,'空',1,'壹',2,'贰',3,'叁','其他') from table1
 
 

项目例子:decode(sum(p.pm_ti),null,0,sum(p.pm_ti)) as assetCount

 判断这个内资的统计的总额,如果为null,显示0,否则就是其本身的值

猜你喜欢

转载自blog.csdn.net/weixin_41321233/article/details/80306163