pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedHow do you do the opposite of regexp_split_to_table?
2+ messages / 2 participants
[nested] [flat]
* How do you do the opposite of regexp_split_to_table?
@ 2010-08-03 20:21 John Gage <jsmgage@numericable.fr>
0 siblings, 1 reply; 2+ messages in thread
From: John Gage @ 2010-08-03 20:21 UTC (permalink / raw)
To: pgsql-sql
I would like to take several rows from a select and have them grouped
into one row with the text contents of one field in all the rows
concatenated into one field in the single row of the group group. The
contents of the other fields are identical across the rows.
This is the complementary action to regexp_split_to_table.
Grouping by summing numerical fields seems to be straightforward, but
grouping by concatenating text fields escapes my search of the
documentation.
Thanking you for your patience,
John
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: How do you do the opposite of regexp_split_to_table?
@ 2010-08-03 20:35 Alvaro Herrera <alvherre@commandprompt.com>
parent: John Gage <jsmgage@numericable.fr>
0 siblings, 0 replies; 2+ messages in thread
From: Alvaro Herrera @ 2010-08-03 20:35 UTC (permalink / raw)
To: John Gage <jsmgage@numericable.fr>; +Cc: pgsql-sql
Excerpts from John Gage's message of mar ago 03 16:21:58 -0400 2010:
> Grouping by summing numerical fields seems to be straightforward, but
> grouping by concatenating text fields escapes my search of the
> documentation.
You can create a new custom aggregate function that does this. It's
pretty straightforward. There are examples in the archives (search for
text_concat), but there's also a more modern way involving array_agg and
array_to_string.
--
Álvaro Herrera <alvherre@commandprompt.com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2010-08-03 20:35 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-08-03 20:21 How do you do the opposite of regexp_split_to_table? John Gage <jsmgage@numericable.fr>
2010-08-03 20:35 ` Alvaro Herrera <alvherre@commandprompt.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox