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 1FA10474E44 for ; Fri, 7 Mar 2003 08:27:22 -0500 (EST) Received: by ouinch.absolight.com (Postfix, from userid 1007) id 66D652A21; Fri, 7 Mar 2003 14:27:25 +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 C05622A0E; Fri, 7 Mar 2003 14:27:24 +0100 (CET) Date: Fri, 07 Mar 2003 14:29:19 +0100 From: Mathieu Arnold To: Christoph Haller , pgsql-sql@postgresql.org Subject: Re: problem with subselect Message-ID: <2065359439.1047047359@andromede.reaumur.absolight.net> In-Reply-To: <3E689B74.703028EF@rodos.fzk.de> References: <3E689B74.703028EF@rodos.fzk.de> X-Mailer: Mulberry/3.0.2 (Win32) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Archive-Number: 200303/192 X-Sequence-Number: 12232 --En cette belle journ=E9e de vendredi 7 mars 2003 14:15 +0100, -- Christoph Haller =E9crivait : |>=20 |> I have this : |>=20 |> 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) |> <=3D 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) |>=20 |> which does not work... telling me that |>=20 |> "Sub-SELECT uses un-GROUPed attribute f.date_creation from outer | query" |> Which is not really true, but some way is... |>=20 |> What I want is to get the sum of the month, and the sum of the month | and |> the previous. |>=20 |> If someone has a clue, something, anything... :) |>=20 | Try | ... GROUP BY mois ; Already tried, not working either. --=20 Mathieu Arnold