我正在做一堆求和查询:SELECT col1 + col2 + col3 + ...
某些列中的某些值为空。我正在通过做检查它们
SELECT CASE WHEN col1 is not null and col2 is not null and ...
我想知道是否有更简洁的语法来完成这项任务。
最佳答案
好吧,因为the sum of any number and null
is null
,您可以执行以下操作(填充明显的 ...
):
select big_honking_sum
from(
select col1+col2+col3+...+coln as big_honking_sum
from some_table
)sum
where big_honking_sum is not null;
关于sql - postgresql - 排除任何带有空值的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9673370/