如何编写一个只对列不为空的列表中的值求和的表达式?
示例:
2.1 4 5 23
4 1 2 null
1 3.1 5 1
8 .5 1 null
我想得到第一列的总和到所有没有最后一列的行。所以我的回答是2.1 + 1 = 3.1。是否可以在Sum表达式中使用'where'子句?或者我怎么能用Sum-if来完成这个?
答案 0 :(得分:1)
看看这是否有帮助
select sum(field_1) from table_name where last_field is not null