Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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

In response to

pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group