pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How fetch multiple rows into one text-field?
2+ messages / 2 participants
[nested] [flat]

* How fetch multiple rows into one text-field?
@ 2009-07-31 20:09 Andreas <maps.on@gmx.net>
  2009-07-31 23:29 ` Re: How fetch multiple rows into one text-field? Joshua Tolley <eggyknap@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Andreas @ 2009-07-31 20:09 UTC (permalink / raw)
  To: pgsql-sql

Hi,

how can I fetch multiple rows into one text-field?
I need the contents of some log-infos condensed into a single text to 
show in a report.

There is a log with a single record per event.
The log is like this   (log_id, case_id, log_date, log_category, log_notes)
I need a date-ordered list of log-date, -category, -notes   of all 
log-events of the same case-id like
log_date || ' ' || log_category || ' : ' || log_nots
e.g.
20.07.2009 Category 17 : utterly noteworthy notes
21.07.2009 Category 42 : lots more
22.07.2009 Category 17 : still more drivel

The report consists of a couple of case-infos and should look like
case_id, case_name, case_all_log_events

Is there a way to do this?

regards
andreas



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: How fetch multiple rows into one text-field?
  2009-07-31 20:09 How fetch multiple rows into one text-field? Andreas <maps.on@gmx.net>
@ 2009-07-31 23:29 ` Joshua Tolley <eggyknap@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Joshua Tolley @ 2009-07-31 23:29 UTC (permalink / raw)
  To: Andreas <maps.on@gmx.net>; +Cc: pgsql-sql

On Fri, Jul 31, 2009 at 10:09:46PM +0200, Andreas wrote:
> Hi,
>
> how can I fetch multiple rows into one text-field?
> I need the contents of some log-infos condensed into a single text to  
> show in a report.

It sounds like you might want something like this:

SELECT ... array_to_string(array_accum(log_notes, '<some delimiter>')) FROM...

You might need to add array_accum manually; before 8.4 it wasn't built in.
See http://www.postgresql.org/docs/8.3/static/xaggr.html

--
Joshua Tolley / eggyknap
End Point Corporation
http://www.endpoint.com

Attachments:

  signature.asc (application/pgp-signature, 196B) download

^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2009-07-31 23:29 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-07-31 20:09 How fetch multiple rows into one text-field? Andreas <maps.on@gmx.net>
2009-07-31 23:29 ` Joshua Tolley <eggyknap@gmail.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