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)
--
TIP 6: ¿Has buscado en los archivos de nuestra lista de correo?
               http://archives.postgresql.org/pgsql-es-ayuda

Responder a