problem with subselect - Mailing list pgsql-sql

From Mathieu Arnold
Subject problem with subselect
Date
Msg-id 2063882566.1047045882@andromede.reaumur.absolight.net
Whole thread Raw
Responses Re: problem with subselect
List pgsql-sql
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




pgsql-sql by date:

Previous
From: Achilleus Mantzios
Date:
Subject: Re: Help on indexing timestamps
Next
From: Andre Schubert
Date:
Subject: Re: Help on indexing timestamps