Re: Cast question (NULL -> NUMERIC) - Mailing list pgsql-novice

From Tom Lane
Subject Re: Cast question (NULL -> NUMERIC)
Date
Msg-id 18652.995058685@sss.pgh.pa.us
Whole thread Raw
In response to Cast question (NULL -> NUMERIC)  (Henry House <hajhouse@houseag.com>)
Responses Re: Cast question (NULL -> NUMERIC)
List pgsql-novice
Henry House <hajhouse@houseag.com> writes:
> the balance forward of the amount column for the user-suplied date correcly
> unless the user supplies a $startdate such that no culumns are being added.
> In this case NULL is returned.

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

pgsql-novice by date:

Previous
From: Henry House
Date:
Subject: Cast question (NULL -> NUMERIC)
Next
From: Henry House
Date:
Subject: Re: Cast question (NULL -> NUMERIC)