Re: Cast question (NULL -> NUMERIC)

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Cast question (NULL -> NUMERIC)
Дата
Msg-id 18652.995058685@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Cast question (NULL -> NUMERIC)  (Henry House <hajhouse@houseag.com>)
Ответы Re: Cast question (NULL -> NUMERIC)  (Henry House <hajhouse@houseag.com>)
Список 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 по дате отправления:

Предыдущее
От: Henry House
Дата:
Сообщение: Cast question (NULL -> NUMERIC)
Следующее
От: Henry House
Дата:
Сообщение: Re: Cast question (NULL -> NUMERIC)