pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rod Taylor <rbt@rbt.ca>
To: Richard Huxton <dev@archonet.com>
Cc: Chadwick Rolfs <cmr@shell.gis.net>
Cc: Frank Bax <fbax@sympatico.ca>
Cc: pgsql-php@postgresql.org
Cc: pgsql-sql@postgresql.org
Subject: Re: faster output from php and postgres
Date: 27 May 2003 14:54:36 -0400
Message-ID: <1054061675.93507.40.camel@jester> (raw)
In-Reply-To: <200305271919.05735.dev@archonet.com>
References: <Pine.GSO.4.05.10305271222540.10146-100000@shell.gis.net>
	<200305271919.05735.dev@archonet.com>

On Tue, 2003-05-27 at 14:19, Richard Huxton wrote:
> On Tuesday 27 May 2003 5:34 pm, Chadwick Rolfs wrote:
> > So, I have the same problem, but I need all authors for each publication
> > to show up in it's own column.  I tried the full join query from a
> > suggestion off pgsql-sql, but it only returns ONE author id TWICE instead
> > of ALL authors at once.
> >
> > I'll do some RTFMing of the joins.. and post any results I get
> >
> > BUT, right now, looping over each publication with php isn't taking that
> > long.  I would like to know how to make this query, though!
> >
> > Please let me know how to get a result like:
> > ____________________________________________________
> >
> > |All Authors|Title|Source|Year|Type|Length|Keywords|
> 
> Well, if you search the archives for terms "text", "concat", "aggregate" you 
> should come up with one solution. This involves writing your own aggregate 
> function, like SUM() but for text. Don't worry, it's not difficult. The only 
> issue is that you won't be able to guarantee the order of authors in the 
> field.

If order is required:

SELECT custom_aggregate(author) as authors
  FROM (SELECT author FROM table ORDER BY author) AS tab;

The above should give you authors in alphabetical order if
custom_aggregate() was written to concatenate text.


-- 
Rod Taylor <rbt@rbt.ca>

PGP Key: http://www.rbt.ca/rbtpub.asc

Attachments:

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

view thread (15+ messages)  latest in thread

Message-ID: <1054061675.93507.40.camel@jester>
Permalink:  ../1054061675.93507.40.camel@jester/
Also on:    postgresql.org/message-id/1054061675.93507.40.camel@jester

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: rbt@rbt.ca, dev@archonet.com, cmr@shell.gis.net, fbax@sympatico.ca, pgsql-php@postgresql.org
  Subject: Re: faster output from php and postgres
  In-Reply-To: <1054061675.93507.40.camel@jester>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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