pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: terry@ashtonwoodshomes.com, "Postgresql Sql Group (E-mail)" <pgsql-sql@postgresql.org>
Subject: Re: Return relation table data in a single value CSV
Date: Wed, 18 Feb 2004 09:29:42 +0000
Message-ID: <200402180929.42103.dev@archonet.com> (raw)
In-Reply-To: <18788.1077060834@sss.pgh.pa.us>
References: <007701c3f591$5acc3020$2766f30a@development.greatgulfhomes.com>
	<200402172104.38307.dev@archonet.com>
	<18788.1077060834@sss.pgh.pa.us>

On Tuesday 17 February 2004 23:33, Tom Lane wrote:
> Richard Huxton <dev@archonet.com> writes:
> > 2. Write a custom aggregate function (like sum()) to do the
> > concatenation. This is easy to do, but the order your ABC get processed
> > in is undefined.
>
> Actually, as of 7.4 it is possible to control the order of inputs to a
> custom aggregate.  You do something like this:
>
> 	SELECT foo, myagg(bar) FROM
> 	  (SELECT foo, bar FROM table ORDER BY foo, baz) AS ss
> 	GROUP BY foo
>
> The inner sub-select must order by the columns that the outer will group
> on; it can then order by additional columns that determine the sort
> order within each group.  Here, myagg() will see its input ordered by
> increasing values of baz.

Hmm - good to know, but I'm always wary of doing this sort of thing. It's 
exactly the sort of trick I look at 18 months later, fail to read my own 
comments and "tidy" it.

-- 
  Richard Huxton
  Archonet Ltd



view thread (4+ messages)

Message-ID: <200402180929.42103.dev@archonet.com>
Permalink:  ../200402180929.42103.dev@archonet.com/
Also on:    postgresql.org/message-id/200402180929.42103.dev@archonet.com

 · 

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: dev@archonet.com, tgl@sss.pgh.pa.us
  Subject: Re: Return relation table data in a single value CSV
  In-Reply-To: <200402180929.42103.dev@archonet.com>

* 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