Re: Cast question (NULL -> NUMERIC)

From: Henry House <hajhouse(at)houseag(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Cast question (NULL -> NUMERIC)
Date: 2001-07-14 17:35:06
Message-ID: 20010714103506.A20615@houseag.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Fri, Jul 13, 2001 at 05:11:25PM -0400, Tom Lane wrote:
[..]
> Yeah, for some unfathomable reason SQL92 defines SUM() of no rows to
> return NULL, rather than zero as any mathematician would say it should.
>
> Use COALESCE(SUM(...), 0) to replace the null result by 0.
>
> regards, tom lane

That did the trick. Thanks!

--
Henry House
OpenPGP key available from http://romana.hajhouse.org/hajhouse.asc

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Barry Hoggard 2001-07-15 02:52:24 Returning a value from an update or insert using DBD::Pg
Previous Message Todd T. Fries 2001-07-13 22:03:49 Re: Serial field