Re: Sorting items in aggregate function
От | Michael Fuhr |
---|---|
Тема | Re: Sorting items in aggregate function |
Дата | |
Msg-id | 20060912181759.GA66966@winnie.fuhr.org обсуждение исходный текст |
Ответ на | Sorting items in aggregate function (Steven Murdoch <psql+Steven.Murdoch@cl.cam.ac.uk>) |
Ответы |
Re: Sorting items in aggregate function
|
Список | pgsql-sql |
On Tue, Sep 12, 2006 at 04:46:28PM +0100, Steven Murdoch wrote: > Here is an example of a setup and what I could like to achieve. Does > anyone have suggestions on what is the best way to get the desired > result? Use the aggregate over an ordered subquery: SELECT name, trim(concat(code || ' ')) AS codes FROM ( SELECT a.name, b.code FROM a LEFT JOIN ab ON a.id = ab.a_id LEFT JOIN b ON ab.b_id = b.id ORDER BY b.code ) AS s GROUP BY name ORDER BY name; Here's a comment from Tom Lane, one of the core developers, on feeding the aggregate based on the subquery's order: http://archives.postgresql.org/pgsql-general/2005-09/msg00047.php -- Michael Fuhr
В списке pgsql-sql по дате отправления: