I have a SELECT statement that gives me a result like this:
SONG ARTIST
---
Song1 Artist1
Song1 Artist2
Song1 Artist3
Song2 Artist2
Song3 Artist4
Song4 Artist1
Song5 Artist4
As you can see, the same song may belong to more tha
On Nov 28, 2012, at 1:33 PM, JORGE MALDONADO wrote:
> I have a SELECT statement that gives me a result like this:
>
> SONG ARTIST
> ---
> Song1 Artist1
> Song1 Artist2
> Song1 Artist3
> Song2 Artist2
> Song3 Artist4
> Song4 Artist1
You need to use the array_agg() and array_to_string() functions.
Best,
Oliver
Enviado via iPhone
Em 28/11/2012, às 06:33 PM, JORGE MALDONADO escreveu:
> I have a SELECT statement that gives me a result like this:
>
> SONG ARTIST
> ---
> Song1 Artist1
> -Original Message-
> From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-
> ow...@postgresql.org] On Behalf Of Oliver d'Azevedo Cristina
> Sent: Wednesday, November 28, 2012 1:42 PM
> To: JORGE MALDONADO
> Cc: pgsql-sql@postgresql.org
> Subject: Re: [SQL] Joining several rows into only
Hi,
I use \copy to output tables into CSV files:
\copy (SELECT ...) TO 'a.csv' CSV
but for long and complex SELECT statements, it is cumbersome and
confusing to write everything in a single line, and multiline statements
don't seem to be accepted. Is there an alternative, or am I missing an
con