Cast question (NULL -> NUMERIC)

From: Henry House <hajhouse(at)houseag(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Cast question (NULL -> NUMERIC)
Date: 2001-07-13 18:53:38
Message-ID: 20010713115338.A12955@houseag.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I have the following query:

SELECT cast( sum(amount) AS NUMERIC(9,2) ) ...
WHERE postdate < $startdate

(where $startdate is replaced with the user's entry at runtime) which returns
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. I want to receive 0.00 in this case instead of
NULL, so I added the cast above, but NULL is still returned. Any ideas?

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

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2001-07-13 21:11:25 Re: Cast question (NULL -> NUMERIC)
Previous Message GH 2001-07-13 18:46:46 Re: Silly newbie questions