Re: [SQL] Ugly group by problem

2006-03-30 Thread Achilleus Mantzios
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

Re: [SQL] Ugly group by problem

2006-03-30 Thread Markus Schaber
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

Re: [SQL] Ugly group by problem

2006-03-29 Thread Niklas Johansson
On 29 mar 2006, at 17.42, Achilleus Mantzios wrote: The _int_union trick is to force the arrays to have unique values. The order by has the meaning that '{5,23}' and '{23,5}' should be treated the same way. I didn't have the _int_union function. Is it internal? What PG- version did you use

Re: [SQL] Ugly group by problem

2006-03-29 Thread Achilleus Mantzios
O Markus Schaber έγραψε στις Mar 29, 2006 : > Hello, > > I have a table filled from third party that basically has the following > structure: > > link_id | feat_id | other | columns... > +-+---+--- > 1 | 2 | ... > 2 | 5 | ... > 2 | 23

[SQL] Ugly group by problem

2006-03-29 Thread Markus Schaber
Hello, I have a table filled from third party that basically has the following structure: link_id | feat_id | other | columns... +-+---+--- 1 | 2 | ... 2 | 5 | ... 2 | 23 | ... 3 | 5 | ... 3 | 23 | some | data