pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mathieu Arnold <mat@mat.cc>
To: Stephan Szabo <sszabo@megazone23.bigpanda.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: sql subqueries problem
Date: Tue, 20 Aug 2002 17:34:10 +0200
Message-ID: <104534722.1029864850@andromede.reaumur.absolight.net> (raw)
In-Reply-To: <20020820073326.S42396-100000@megazone23.bigpanda.com>
References: <20020820073326.S42396-100000@megazone23.bigpanda.com>

>> 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



view thread (5+ messages)

Message-ID: <104534722.1029864850@andromede.reaumur.absolight.net>
Permalink:  ../104534722.1029864850@andromede.reaumur.absolight.net/
Also on:    postgresql.org/message-id/104534722.1029864850@andromede.reaumur.absolight.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mat@mat.cc, sszabo@megazone23.bigpanda.com
  Subject: Re: sql subqueries problem
  In-Reply-To: <104534722.1029864850@andromede.reaumur.absolight.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox