我有一个看起来像这样的 SQL 查询:
SELECT
COALESCE(field1, 0) AS field1,
COALESCE(field2, 0) AS field2,
COALESCE(field3 - field1 - field2, 0) AS field
FROM ...
However the problem with it is that given say:
field1 = 1
field2 = 0
field3 = 2
显示输出时,字段 3 显示 0,尽管 2 - 1 - 0 = 1。
COALESCE 用于我离开外部加入一些可能导致 Null 值的表。
如果 field3 为空,我也会有任何问题吗?
谢谢