>> I've tried, but, as the subselect is an aggregate, I can't get it (maybe >> I don't know enough about it to do it :) > > Right, that'd make it harder. :) > > Hmm, would something like: > > FROM > (select *, > (select sum(ff.montant_ttc/df.taux) from facture ff join > devise as df using (id_devise) where ff.date_creation <= > f.date_creation and ff.id_client=f.id_client > group by ff.id_client) as facture, > (select sum(rr.montant/dr.taux) from remise as rr join > devise as dr using (id_devise) where rr.date_paiement <= > f.date_creation and rr.id_client=f.id_client > group by rr.id_client) as remise > From facture f > ); > > give you something closer to what you want?
that's exactly it, I guess that I was not twisted enough for that one :) -- Mathieu Arnold ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html