--這兩個是不同的概念....如果存在null值,結果也會不一樣.
create table t(c1 int,c2 int)
insert into t select 1,2
insert into t select 1,2
insert into t select 1,2
insert into t select null,2
insert into t select null,2
insert into t select 1,2
insert into t select 1,2select sum(c1)+sum(c2),sum(c1+c2) from tdrop table t
----------- ----------- 
19          15Warning: Null value is eliminated by an aggregate or other SET operation.

解决方案 »

  1.   

    Sum(a+b+c...n)
     這個高
    當然是應該這樣寫Sum(isnull(a,0)+isnull(b,0)+isnull(c,0)...n)
      

  2.   

    create table t(c1 int,c2 int)
    insert into t select 1,2
    insert into t select 1,2
    insert into t select 1,2
    insert into t select null,2
    insert into t select null,2
    insert into t select 1,2
    insert into t select 1,2select sum(isnull(c1,0)+isnull(c2,0)) as a,
           sum(isnull(c1,0))+sum(isnull(c2,0)) as b 
          
     
    from tdrop table t测试结果:
    sum(isnull(c1,0)+isnull(c2,0))
    效率高!
      

  3.   

    select sum(isnull(c1,0)+isnull(c2,0))+isnull(c1,0)+(isnull(c2,0))
    from table;
      

  4.   

    sum是聚合运算,很费时间的所以越少越好select sum(isnull(c1,0)+isnull(c2,0))+isnull(c1,0)+(isnull(c2,0))
    from table
      

  5.   

    聚合函数遇到null时会呼略,而+运到null结果仍为null,一个先+再聚合,一个先聚合再+,所以二者结果都不一样,根本无法比较
      

  6.   

    null值不能用来根其他值比较
    譬如 if null = 1 
    这种比较既不会得到false也不会得到true值。
      

  7.   

    忘了说,是非空的条件下,也就是都是float