From: Achilleus Mantzios <achill@matrix.gatewaynet.com>
To: Markus Schaber <schabi@logix-tt.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Ugly group by problem
Date: Thu, 30 Mar 2006 13:20:23 +0300 (EEST)
Message-ID: <Pine.LNX.4.44.0603301317350.23284-100000@matrix.gatewaynet.com> (raw)
In-Reply-To: <442A9D3A.7010605@logix-tt.com>
O Markus Schaber Ýãñáøå óôéò Mar 29, 2006 :
> 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.
Just some facts:
sort(uniq(int[])) has the same effect as select DISTINCT... ORDER BY
DISTINCT. ORDER BY is ofcourse more intuitive and does not need
contrib/intarray.
In fact , i dont even remember why i didnt write the query with
DISTINCT... in the first place :)
>
> Markus
>
>
>
--
-Achilleus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: achill@matrix.gatewaynet.com, schabi@logix-tt.com
Subject: Re: Ugly group by problem
In-Reply-To: <Pine.LNX.4.44.0603301317350.23284-100000@matrix.gatewaynet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox