Re: Ordering of data on calls to user defined aggregate. - Mailing list pgsql-general

From Joel Burton
Subject Re: Ordering of data on calls to user defined aggregate.
Date
Msg-id 20020518211304.5F3522B811@temp.joelburton.com
Whole thread Raw
In response to Ordering of data on calls to user defined aggregate.  (Tim Hart <timjhart@shaw.ca>)
Responses Re: Ordering of data on calls to user defined aggregate.
List pgsql-general
Tim Hart <timjhart@shaw.ca> said:

> So I tried a query like this:
>
> select fk, concat_with_and(name) from ( select fk, name from foo order
> by fk, name) sub_select group by fk;
>
>  From just eyeballing the first 10 to 12 pages of the results, all but 2
> records had the names in alphabetical order. So I removed the subselect
> and ran the query again - this time paying attention to the ordering
> within names. Very few entries in the 'names' column were in
> alphabetical order at all.

Hmmm... in my (small) test case, they were all alphabetized.

I didn't think that subquery sort orders were guaranteed, though, so perhaps it's okay that yours weren't.

Can you try with GROUP BY fk, name in the subquery? That works, too, on my small test case, and that should be
guaranteedbehavior in a subquery. Let's see how that works with your data set. 

- J.

pgsql-general by date:

Previous
From: "Wm. G. Urquhart"
Date:
Subject: Re: More on "What am I doing wrong!"
Next
From: Laurette Cisneros
Date:
Subject: another psql question