From: | Joost Kraaijeveld <J(dot)Kraaijeveld(at)Askesis(dot)nl> |
---|---|
To: | Frank van Vugt <ftm(dot)van(dot)vugt(at)foxi(dot)nl> |
Cc: | "Pgsql-sql(at)postgresql(dot)org" <Pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Help with simple SQL query? |
Date: | 2005-10-05 13:19:40 |
Message-ID: | 1128518380.3655.226.camel@Panoramix |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Wed, 2005-10-05 at 14:21 +0200, Frank van Vugt wrote:
> Hi Joost,
>
> Try joining and comparing the order table with/to an aggregated orderline
> table, something like this:
>
> select order_id, order_price, sum_price, order_price - sum_price as diff
> from order, (select parent_order_id, sum(orderline_price) as sum_price
> from orderline group by parent_order_id) as foo
> where order_id = parent_order_id
> and order_price != sum_price
>
>
> This should prove to be as efficient as it gets ;)
How nice. An answer between the questions. And a working anser!. Which
manual did I miss ;-)
Thanks.
--
Groeten,
Joost Kraaijeveld
Askesis B.V.
Molukkenstraat 14
6524NB Nijmegen
tel: 024-3888063 / 06-51855277
fax: 024-3608416
e-mail: J(dot)Kraaijeveld(at)Askesis(dot)nl
web: www.askesis.nl
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Huxton | 2005-10-05 15:01:15 | Re: MOVE in SQL vs PLPGSQL |
Previous Message | Frank van Vugt | 2005-10-05 12:21:56 | Re: Help with simple SQL query? |