X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 647F29FA1B0 for ; Tue, 2 May 2006 21:24:42 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 87536-06 for ; Tue, 2 May 2006 21:24:34 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from wx-out-0102.google.com (wx-out-0102.google.com [66.249.82.195]) by postgresql.org (Postfix) with ESMTP id 65EA19F9C9E for ; Tue, 2 May 2006 21:24:34 -0300 (ADT) Received: by wx-out-0102.google.com with SMTP id s10so35299wxc for ; Tue, 02 May 2006 17:24:33 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; b=lqX+WiY6eI34tDEXNNR6PuuDeSPwGftkO+4gFSSAQu0EgCqbxiVeEJCZtnPvjGxoYGpYNvGpJVFk5GxhRQIzrL/QqfGF4s7I1iHAtTXFVJbv1hhxB5a+xBkExn34Y2tnVfxNR9emZvokHcEy3miE8MjunzBYVYj/H36nfd6q3oQ= Received: by 10.70.103.10 with SMTP id a10mr389159wxc; Tue, 02 May 2006 17:24:33 -0700 (PDT) Received: from ?200.96.76.216? ( [200.96.76.216]) by mx.gmail.com with ESMTP id i13sm6119701wxd.2006.05.02.17.24.31; Tue, 02 May 2006 17:24:32 -0700 (PDT) Message-ID: <4457F83C.7020505@gmail.com> Date: Tue, 02 May 2006 21:24:28 -0300 From: =?ISO-8859-1?Q?Everton_Lu=EDs_Berz?= User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) MIME-Version: 1.0 To: Volkan YAZICI CC: pgsql-sql@postgresql.org Subject: Re: Sorting aggregate column contents References: <4457C86F.8040303@gmail.com> <20060502211340.GA188@alamut> In-Reply-To: <20060502211340.GA188@alamut> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/19 X-Sequence-Number: 25050 It works fine. But I wouldn't like using subselect's, then if somebody else knows about an operator or something like that to put on the aggregator, please tell me. Volkan YAZICI escreveu: > 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. > >