Subject Re: [ib-support] Count value on field
Author Claudio Valderrama C.
""Bayu"" <bayu2000@...> wrote in message
news:004301c1d018$3064f600$2c6c053d@bayu01...
> Hello Martin and Luc
>
> > NULL means the state of 'unknown'.
> >
> > value + unknown = unknown
>
> But why select sum(d_imip) from transaksi will give me the right result ?

By design, SUM, AVG, MAX and MIN skip null values. The only case when those
functions return NULL is when the whole column is NULL. In contrast, COUNT
never returns NULL. The net result is that in a table with fields A, B & C
that are nullable, the expression
select sum (A + B + C)
gives different results than
select sum (A) + sum (B) + sum (C)
in the general case.

C.
--
Claudio Valderrama C. - http://www.cvalde.com - http://www.firebirdSql.org
Independent developer
Owner of the Interbase® WebRing