X-Original-To: pgsql-sql@postgresql.org Received: from ouinch.absolight.com (mx3.absolight.net [212.43.217.9]) by postgresql.org (Postfix) with ESMTP id E36E3476313 for ; Fri, 7 Mar 2003 08:02:45 -0500 (EST) Received: by ouinch.absolight.com (Postfix, from userid 1007) id AD4A12A09; Fri, 7 Mar 2003 14:02:48 +0100 (CET) X-Original-To: pgsql-sql@postgresql.org Received: from andromede.reaumur.absolight.net (andromede.reaumur.absolight.net [212.43.217.61]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (Client did not present a certificate) by ouinch.absolight.com (Postfix) with ESMTP id 205182A07 for ; Fri, 7 Mar 2003 14:02:48 +0100 (CET) Date: Fri, 07 Mar 2003 14:04:42 +0100 From: Mathieu Arnold To: pgsql-sql@postgresql.org Subject: problem with subselect Message-ID: <2063882566.1047045882@andromede.reaumur.absolight.net> X-Mailer: Mulberry/3.0.2 (Win32) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Archive-Number: 200303/189 X-Sequence-Number: 12229 Hi, I have this : SELECT date_trunc('month', f.date_creation) as mois, sum(f.montant_ttc / d.taux) as facture, (SELECT sum(f2.montant_ttc / d2.taux) as facture2 FROM facture AS f2 JOIN devise AS d2 USING (id_devise) WHERE date_trunc('month', f2.date_creation) <= date_trunc('month', f.date_creation)) FROM facture AS f JOIN devise AS d USING (id_devise) GROUP BY date_trunc('month', f.date_creation) which does not work... telling me that "Sub-SELECT uses un-GROUPed attribute f.date_creation from outer query" Which is not really true, but some way is... What I want is to get the sum of the month, and the sum of the month and the previous. If someone has a clue, something, anything... :) -- Mathieu Arnold