Re: Sorting aggregate column contents

From: Volkan YAZICI <yazicivo(at)ttnet(dot)net(dot)tr>
To: Everton Luís Berz <everton(dot)berz(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Sorting aggregate column contents
Date: 2006-05-02 21:13:40
Message-ID: 20060502211340.GA188@alamut
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On May 02 06:00, Everton Luís Berz wrote:
> Is it possible to sort the content of an aggregate text column?
>
> Query:
> select s.name, ag_concat(c.name) from state s
> inner join city c on (c.idstate = s.idstate)
> group by s.name
> order by s.name;

IMHO, you can receive results ordered by using a subselect:

SELECT T.s_name, ag_concat(T.c_name)
FROM (SELECT s.name, c.name
FROM state AS s
INNER JOIN city AS c ON (c.idstate = s.idstate)
ORDER BY s.name, c.name) AS T (s_name, c_name)
GROUP BY T.s_name;

Regards.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Bruno Wolff III 2006-05-03 00:16:02 Re: Sorting aggregate column contents
Previous Message Everton Luís Berz 2006-05-02 21:00:31 Sorting aggregate column contents