From: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
---|---|
To: | Juan Romero <jgromero(at)gmail(dot)com> |
Cc: | Sergio Valdes Hurtado <svh(dot)pgsql(at)gmail(dot)com>, Lista PostgreSql <pgsql-es-ayuda(at)postgresql(dot)org> |
Subject: | Re: Concatenar datos |
Date: | 2009-08-17 00:22:03 |
Message-ID: | 20090817002202.GE24620@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Alvaro Herrera escribió:
> Juan Romero escribió:
>
> > Si. Utilizando funciones agregadas[1]. En la lista hace algun tiempo
> > Alvaro Herrera dejo una funcion que, me parece, hace justamente eso
> > que necesitas[2]
>
> Ese es un mecanismo que quedó obsoleto desde que se puede usar
> array_agg. En ese mismo thread creo que alguien explicó cómo se hacía.
No lo vi así que aquí lo pongo:
alvherre=# create table test (a int);
iCREATE TABLE
alvherre=# insert into test values (1), (2), (3);
INSERT 0 3
alvherre=# select array_agg(a) from test;
array_agg
-----------
{1,2,3}
(1 fila)
alvherre=# select array_to_string(array_agg(a), ' - ') from test;
array_to_string
-----------------
1 - 2 - 3
(1 fila)
--
Alvaro Herrera http://www.advogato.org/person/alvherre
"Ah, spring... when a young penguin's fancy lightly turns to thoughts of ...
Beta testing!" (Fedora 9 beta announcement)
From | Date | Subject | |
---|---|---|---|
Next Message | Sergio Valdes Hurtado | 2009-08-17 13:14:28 | Re: Concatenar datos |
Previous Message | Alvaro Herrera | 2009-08-17 00:14:21 | Re: Concatenar datos |