Search Postgresql Archives

Re: Denormalizing via SQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Dec 11, 2011, at 19:40, Robert James <srobertjames@xxxxxxxxx> wrote:

> I have a query returning:
> 
> name | product_id
> Bob | 1
> Bob | 2
> Charles | 1
> Charles | 4
> 
> To make it compatible with a legacy app, I need to convert it to this form:
> name | product_ids
> Bob | "1,2"
> Charles | "1,4"
> 
> (Before you jump "That's not normal!" - I know.  I didn't write the
> app.  I just need to meet its interface.)
> 
> What's the best way to do this in Postgres? Is there a way to do it
> via pure SQL?
> 
> -- 
> Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

Look at the STRING_AGG aggregate function.

David J.

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux