Re: coalesce and aggregate functions

Поиск
Список
Период
Сортировка
От Gregory Stark
Тема Re: coalesce and aggregate functions
Дата
Msg-id 87slfljff8.fsf@enterprisedb.com
обсуждение исходный текст
Ответ на coalesce and aggregate functions  (Patrick Welche <prlw1@newn.cam.ac.uk>)
Список pgsql-hackers
"Patrick Welche" <prlw1@newn.cam.ac.uk> writes:

> Is this a bug, or don't I understand coalesce()?
>
> select coalesce(0,sum(b)) from test where a=2;  -- 0 !
>
> So when I use coalesce() with sum(), I always get the constant. I would
> have expected it only in the case where sum() returns null..

Coalesce will return the first argument if it's not null. 
You may be thinking about the arguments in reverse order?

--  Gregory Stark EnterpriseDB          http://www.enterprisedb.com


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: coalesce and aggregate functions
Следующее
От: "Kevin Grittner"
Дата:
Сообщение: Re: coalesce and aggregate functions