From: | bricklen <bricklen(at)gmail(dot)com> |
---|---|
To: | Andreas Forø Tollefsen <andreasft(at)gmail(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: ARRAY_AGG and COUNT |
Date: | 2011-02-17 22:54:02 |
Message-ID: | AANLkTinVgQKaF98eUrDMiC8wz=UX3Bukc-L_D4X3-+hM@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Thu, Feb 17, 2011 at 12:11 PM, Andreas Forø Tollefsen
<andreasft(at)gmail(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | Sivannarayanreddy | 2011-02-18 05:44:53 | Re: Function compile error |
Previous Message | Andreas Forø Tollefsen | 2011-02-17 20:11:37 | Re: ARRAY_AGG and COUNT |