sum grouping with NULL/ Not null

Clark Pokejn
Дата: 27.11.2009 16:10:58
Simple -
select sum(x) from (select null x from dual union all (select 1 x from dual)). The result is 1
But sum(null+1) is Null.

non ANSI?
tru55
Дата: 27.11.2009 16:13:41
SQL Reference

Aggregate Functions

All aggregate functions except COUNT(*) and GROUPING ignore nulls.
suPPLer
Дата: 27.11.2009 16:18:58
Clark Pokejn
Simple -
select sum(x) from (select null x from dual union all (select 1 x from dual)). The result is 1
But sum(null+1) is Null.

non ANSI?


Подсказка: NULL + 1 = NULL.
_Alex_SMIRNOV_
Дата: 27.11.2009 16:22:44
- Групповая функция SUM пропускает NULL значения.
- NULL + 1 <> select sum(x) from (select null x from dual union all select 1 x from dual)