Re: sql subqueries problem - Mailing list pgsql-sql

From Mathieu Arnold
Subject Re: sql subqueries problem
Date
Msg-id 104534722.1029864850@andromede.reaumur.absolight.net
Whole thread Raw
In response to Re: sql subqueries problem  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-sql
>> 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


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: bulk imports with sequence
Next
From: Lucas Brasilino
Date:
Subject: Problem with timestamp field/time function.. (upgrading from 7.0 to 7.2.1)