Re: Sorting items in aggregate function - Mailing list pgsql-sql

From Volkan YAZICI
Subject Re: Sorting items in aggregate function
Date
Msg-id 20060912182439.GB1373@alamut
Whole thread Raw
In response to Sorting items in aggregate function  (Steven Murdoch <psql+Steven.Murdoch@cl.cam.ac.uk>)
List pgsql-sql
On Sep 12 04:46, Steven Murdoch wrote:
> I would like to concatenate sorted strings in an aggregate function. I
> found a way to do it without sorting[1], but not with.

If the array elements will be made of integers, then you can use sort()
procedure comes with intarray contrib module. For instance,
 SELECT concat(T.sorted_arr)   FROM (SELECT sort(arr) FROM tbl) AS T (sorted_arr);

If related column will also include text values, you can create a
suitable sort() procedure for text[] type and use it instead.


Regards.


pgsql-sql by date:

Previous
From: "Aaron Bono"
Date:
Subject: Re: on connect/on disconnect
Next
From: "Aaron Bono"
Date:
Subject: Re: Two optimization questions