Re: Re: plpgsql, I have a solution, want to see if there is a cleaner/better one. Taking vertical list and comma separating it onto a row

From: "David Johnston" <polobo(at)yahoo(dot)com>
To: "'Henry Drexler'" <alonup8tb(at)gmail(dot)com>, "'Thomas Kellerer'" <spam_eater(at)gmx(dot)net>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Re: plpgsql, I have a solution, want to see if there is a cleaner/better one. Taking vertical list and comma separating it onto a row
Date: 2011-11-10 17:37:04
Message-ID: 009101cc9fcf$5d086660$17193320$@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

From: pgsql-general-owner(at)postgresql(dot)org
[mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Henry Drexler
Sent: Thursday, November 10, 2011 8:42 AM
To: Thomas Kellerer
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] Re: plpgsql, I have a solution, want to see if there
is a cleaner/better one. Taking vertical list and comma separating it onto a
row

On Thu, Nov 10, 2011 at 8:34 AM, Thomas Kellerer <spam_eater(at)gmx(dot)net> wrote:

SELECT type,
string_agg(color, ',') as organized_by_type
FROM clothes
GROUP BY type;

wow, yes that is cleaner.

Thank you for taking the time - obviously I need to read through the string
functions again.

It isn't a "String Function" but an "Aggregate Function"; classification
can be a pain sometimes - especially when more than one category could
readily apply.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2011-11-10 17:38:37 Re: select from dynamic table names
Previous Message Adrian Klaver 2011-11-10 17:30:30 Re: troubleshooting PGError