X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 33D6611F66D7 for ; Thu, 30 Mar 2006 05:04:39 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 06621-07 for ; Thu, 30 Mar 2006 05:04:38 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.logix-tt.com (unknown [212.211.145.186]) by postgresql.org (Postfix) with ESMTP id 2EAC611F65C6 for ; Thu, 30 Mar 2006 05:04:35 -0400 (AST) Received: from kingfisher.intern.logix-tt.com (T8a9b.t.pppool.de [89.55.138.155]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logix-tt.com (Postfix) with ESMTP id BF6FA657CA; Thu, 30 Mar 2006 11:05:16 +0200 (CEST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 541E6180001ED; Wed, 29 Mar 2006 16:44:12 +0200 (CEST) Message-ID: <442A9D3A.7010605@logix-tt.com> Date: Wed, 29 Mar 2006 16:44:10 +0200 From: Markus Schaber Organization: Logical Tracking and Tracing International AG, Switzerland User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Achilleus Mantzios Cc: pgsql-sql@postgresql.org Subject: Re: Ugly group by problem References: In-Reply-To: X-Enigmail-Version: 0.93.0.0 Content-Type: text/plain; charset=ISO-8859-7 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.113 required=5 tests=[AWL=0.113] X-Spam-Score: 0.113 X-Spam-Level: X-Archive-Number: 200603/460 X-Sequence-Number: 24806 Hi, Achilleus, Achilleus Mantzios wrote: > foodb=# SELECT qoo.foo2,sum(qoo.foo3) from (SELECT mt.link_id as > foo,_int_union(array(select mt2.feat_id from markustest mt2 where > mt2.link_id=mt.link_id order by mt2.feat_id),'{}') as foo2,other::int4 as > foo3 from markustest mt) as qoo GROUP BY qoo.foo2; > foo2 | sum > --------+----- > {2} | 1 > {5,23} | 13 > {23} | 14 > (3 rows) This is much like I intended to do it, but using "select distinct" in the inner select as I don't have _int_union here, and using a temporary table to collect the sets of link ids. Markus -- Markus Schaber | Logical Tracking&Tracing International AG Dipl. Inf. | Software Development GIS Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org