Re: not quite a cross tab query...

From: darren(at)ontrenet(dot)com
To: "Richard Greenwood" <richard(dot)greenwood(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: not quite a cross tab query...
Date: 2009-03-05 19:27:15
Message-ID: 57959.38.104.58.186.1236281235.squirrel@webmail11.pair.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Have you tried using "group by"?

> Hello pgsql listers,
>
> I've got a problem that is similar to, but I don't think identical to,
> a cross tab query. My data looks like:
> ID | CAT
> 1 | A
> 1 | B
> 2 | A
> 2 | C
> So for each ID there may be many CAT (categories).
> The client wants it to look like:
> ID | CATS
> 1 | A,B
> 2 | A,C
> Where each ID is unique in the results, and the CAT values are
> concatenated with a comma separator.
>
> There are about 100 unique CAT values. They only way I can see to do
> it is programatically with a for loop. But before I do that I wanted
> to bounce it off the fine minds that inhabit this list.
>
> Thanks,
> Rich
>
> --
> Richard Greenwood
> richard(dot)greenwood(at)gmail(dot)com
> www.greenwoodmap.com
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Steve Atkins 2009-03-05 19:29:55 Re: not quite a cross tab query...
Previous Message A. Kretschmer 2009-03-05 19:22:51 Re: Postgres Cookbook