Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 58AE5633CB9 for ; Wed, 22 Jul 2009 13:22:01 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 21909-01 for ; Wed, 22 Jul 2009 13:21:50 -0300 (ADT) X-Greylist: delayed 00:05:23.943991 by SQLgrey-1.7.6 Received: from lion02.hosting.nl (lion02.hosting.nl [62.129.139.91]) by mail.postgresql.org (Postfix) with ESMTP id AE1DE633C29 for ; Wed, 22 Jul 2009 13:21:50 -0300 (ADT) Received: from lionhead.nl (static.kpn.net [83.232.157.250] (may be forged)) by lion02.hosting.nl (8.13.8/8.13.8) with ESMTP id n6MFOdFQ001722 for ; Wed, 22 Jul 2009 17:24:39 +0200 Received: from lionhead2.lionhead.nl (localhost.localdomain [127.0.0.1]) by lionhead.nl (8.13.8/8.13.8) with ESMTP id n6MGGLlM023731 for ; Wed, 22 Jul 2009 18:16:21 +0200 Date: Wed, 22 Jul 2009 18:16:21 +0200 From: "David Weilers" To: pgsql-sql Message-ID: Subject: Double aggregate problem x-scalix-Hops: 1 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=-10 required=5 tests=none X-Spam-Level: X-Archive-Number: 200907/98 X-Sequence-Number: 32839 Dear anyone, I have the following query: select v.id, array_to_string(array_accum(s.name),', ') as sector ,=20 array_to_string(array_accum(p.name),', ') as provincie from tblvacature=20 v, tblaccount a , tblvacaturesector vs, tblsector s ,=20 tblvacatureprovincie vp, tblprovincie p where v.id =3D 11 and v.account =3D= =20 a.id and vs.vacature =3D v.id and s.id =3D vs.sector and vp.vacature =3D v= =2Eid=20 and p.id =3D vp.provincie group by v.id, v.inserted order by v.inserted=20 desc That currently produces the following output: id | sector | =20 provincie ----+---------------------------------------------------+--------------- ------------------------------------------------------------------- 11 | Gaafjes, Eerder, Gaafjes, Eerder, Gaafjes, Eerder | Noord-Holland,=20 Noord-Holland, Limburg, Limburg, Oost-Vlaanderen, Oost-Vlaanderen If i leave out one aggregate, the result is as i expect (if I leave out=20 'provincie', sector gives): Gaafjes, Eeerder Only two results. I would like both array_accum returning only what they should and not=20 doubles. Any help is appreciated. -- Regards, David Weilers