oracle 除数为0 问题 && decode 用法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/hzq450013155/article/details/79217163
select  100/10  from  dual;     结果为10

但是当除数为0时报错,例如:

select  100/0  from  dual;  

解决方案:

当除数为0时,不让系统提示出错,显示为0

select  decode( a, 0, 0, b/a )  from  dual;

decode函数意义

select  decode( a, b, c, b/a )  from  dual;

参数意义:
当a=b时,输出c,否则输出 b/a

猜你喜欢

转载自blog.csdn.net/hzq450013155/article/details/79217163