Subject AW: [firebird-support] How to change SUM() result NULL to 0
Author Alexander Gräf
> -----Ursprüngliche Nachricht-----
> Von: jasajona [mailto:jon@...]
> Gesendet: Freitag, 26. November 2004 18:45
> An: firebird-support@yahoogroups.com
> Betreff: [firebird-support] How to change SUM() result NULL to 0
>
>
>
> Hello,
>
> How to change SUM() result NULL to 0
>
> -----------------
> select
> sum(field1)
> from
> table1
> group by
> field2
> -----------------
> So if sum(field1) returns NULL I want to see it as 0.
> I tryed many things but no one work (all I get is NULL). Is it FB bug?
> I am
> using 1.5.1 .
>

Try:

select
coalesce(sum(field1), 0)
from
table1
group by
field2

Regards, Alex