oracle查询字段中被除数为0的解决方案

  • Post author:
  • Post category:其他


— 解决被除数为0的方法 一 :case when b then null else a/b end

例:

select case when b=0 then null else a/b end from test

当b=0时,当前字段返回null,否则返回 a/b 的值

— 解决被除数为0的方法 二 :decode(b,0,null,a/b)

例:

select decode(b,0,null,a/b) from test

当b=0时,当前字段返回null,否则返回 a/b 的值



版权声明:本文为weixin_60785926原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。