On Thu, Feb 17, 2011 at 12:11 PM, Andreas Forø Tollefsen <andrea...@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. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql