带有where子句或if的sum表达式

时间:2012-06-01 18:40:10

标签: asp.net-mvc-3 report reporting

如何编写一个只对列不为空的列表中的值求和的表达式?

示例:

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来完成这个?

1 个答案:

答案 0 :(得分:1)

看看这是否有帮助

   select sum(field_1) from table_name where last_field is not null