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>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: 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 14:29:18
Message-ID: EF0A2F89-460B-42F3-8C9B-34E269D1D8EC@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Nov 10, 2011, at 8:22, Henry Drexler <alonup8tb(at)gmail(dot)com> wrote:

> I am thinking there is a better/simpler way, though this is what I have working:
>
> (postgres 9.1)
>
>
> I would like to have the list of colors for each type of clothing to be comma seperated in the end result.
>
> like this:
>
> type organized_by_type
> pants red, blue, orange
> shirt black, gray
>
>
>

Use the STRING_AGG aggregate function instead of writing your own.

David J

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dennis 2011-11-10 14:32:51 Re: How to list installed pl languages
Previous Message Henry Drexler 2011-11-10 13:42:08 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