oracle如果 sum为null记为0

https://blog.csdn.net/ideality_hunter/article/details/70770320

oracle在使用sum函数计算式会遇到这样的情况。

如果sum的值为null,则什么都不显示。想要如果为null,则显示为0,怎么办?

方法1:

select when sum(t.money) is null then    0    else    sum(t.money) from Money t

 

方法2:

 

NVL(Expr1,Expr2)如果Expr1为NULL,返回Expr2的值,否则返回Expr1的值

例如:select NVL(SUM(MONEY) ,0) from tb全都在NVL这儿起作用

select    NVL(SUM(t.money) ,0)  from Money t

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-26
  • 2022-12-23
  • 2021-12-19
  • 2022-02-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-13
  • 2022-12-23
  • 2021-08-16
  • 2022-12-23
  • 2021-11-23
相关资源
相似解决方案