Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 4FEA863451F for ; Wed, 22 Jul 2009 22:25:15 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 80481-02-4 for ; Wed, 22 Jul 2009 22:24:56 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp.insa-lyon.fr (criges14.insa-lyon.fr [134.214.76.242]) by mail.postgresql.org (Postfix) with ESMTP id 0CF606347B6 for ; Wed, 22 Jul 2009 22:24:42 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by smtp.insa-lyon.fr (Postfix) with ESMTP id 6D724F129A; Thu, 23 Jul 2009 03:24:39 +0200 (CEST) X-Virus-Scanned: SMTP at INSA-LYON Received: from smtp.insa-lyon.fr ([127.0.0.1]) by localhost (criges14.insa-lyon.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1vfAp4MbuMZq; Thu, 23 Jul 2009 03:24:38 +0200 (CEST) Received: from [127.0.0.1] (liris.univ-lyon1.fr [134.214.142.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: nhandrianar) by smtp.insa-lyon.fr (Postfix) with ESMTPSA id 29DA9F1284; Thu, 23 Jul 2009 03:24:38 +0200 (CEST) Message-ID: <4A67BB9C.2040707@free.fr> Date: Thu, 23 Jul 2009 03:23:40 +0200 From: nha Organization: Lyon, Rhone, France User-Agent: Thunderbird 2.0.0.6 (Macintosh/20070728) MIME-Version: 1.0 To: David Weilers CC: PgSQL-sql Subject: Re: Double aggregate problem References: <200907222104.38931.peter_e@gmx.net> In-Reply-To: <200907222104.38931.peter_e@gmx.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit 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/101 X-Sequence-Number: 32842 Hello, Le 22/07/09 20:04, Peter Eisentraut a écrit : > On Wednesday 22 July 2009 19:16:21 David Weilers wrote: >> I have the following query: >> >> select v.id, array_to_string(array_accum(s.name),', ') as sector , >> array_to_string(array_accum(p.name),', ') as provincie from tblvacature >> v, tblaccount a , tblvacaturesector vs, tblsector s , >> tblvacatureprovincie vp, tblprovincie p where v.id = 11 and v.account = >> a.id and vs.vacature = v.id and s.id = vs.sector and vp.vacature = v.id >> and p.id = vp.provincie group by v.id, v.inserted order by v.inserted >> desc >> >> That currently produces the following output: > > No one is going to be able to reproduce that without the table definitions and > data. > Peter Eisentraut is right... The rewritten query I suggested is only derived from your original query and implicit data definitions (including constraints). I would like to point 2 things about that rewritten proposed query: - Column 'inserted' is likely missing in the 2nd subquery and in the global join condition; - Duplicity or even multiplicity of value s.name and/or p.name may result depending on the keys of tables (as implicitly mentioned by Peter Eisentraut). Regards. -- nha / Lyon / France.