Re: ARRAY_AGG and COUNT

Поиск
Список
Период
Сортировка
От bricklen
Тема Re: ARRAY_AGG and COUNT
Дата
Msg-id AANLkTinVgQKaF98eUrDMiC8wz=UX3Bukc-L_D4X3-+hM@mail.gmail.com
обсуждение исходный текст
Ответ на Re: ARRAY_AGG and COUNT  (Andreas Forø Tollefsen <andreasft@gmail.com>)
Список pgsql-sql
On Thu, Feb 17, 2011 at 12:11 PM, Andreas Forø Tollefsen
<andreasft@gmail.com> wrote:
> Great. Thanks. Do you have a suggestion on how to ignore the group id's with
> 0 as value?
> I dont want these to be counted.

You can probably select your values in a subquery and filter out the 0
value results in the WHERE clause, then apply your existing query
(with distinct array_agg) to the outer query.
Or another way would be to use a CASE statement to skip the 0 values.
eg.
array_to_string(array_agg(distinct (case when g1id <> 0 then g1id end)
),';') ...

The array_to_string transformation should trim out the NULLs from the
CASE statement.


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

Предыдущее
От: Andreas Forø Tollefsen
Дата:
Сообщение: Re: ARRAY_AGG and COUNT
Следующее
От: Sivannarayanreddy
Дата:
Сообщение: Re: Function compile error