Re: Order By for aggregate functions (Simulating Group_concat)

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Charlotte Pollock <c(dot)pollock(at)bangor(dot)ac(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Order By for aggregate functions (Simulating Group_concat)
Date: 2005-09-01 15:14:41
Message-ID: 20050901151441.GD28062@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Sep 01, 2005 at 10:04:12AM +0100, Charlotte Pollock wrote:
> Hi All
>
> I'm trying to create a aggregate function similar 9but not identical) to
> mysql's group_concat.
>
> What I want to be able to do is pass and order by field to the aggregate so
> I can be certain I get the list of strings in the correct order.

Order them before the aggregate?

SELECT aggregate(field) FROM (SELECT field FROM xxx ORDER BY wherever) x;

Hope this helps,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-09-01 15:16:54 Re: Exception in Query when mixing explicit join and implicit join
Previous Message Kelly Burkhart 2005-09-01 15:07:21 Array of created types