pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
To: Frank van Vugt <ftm.van.vugt@foxi.nl>
Cc: Pgsql-sql@postgresql.org <Pgsql-sql@postgresql.org>
Subject: Re: Help with simple SQL query?
Date: Wed, 05 Oct 2005 15:19:40 +0200
Message-ID: <1128518380.3655.226.camel@Panoramix> (raw)
In-Reply-To: <200510051421.56840.ftm.van.vugt@foxi.nl>
References: <71E37EF6B7DCC1499CEA0316A2568328024BBA0B@loki.wc.globexplorer.net>
	<200510051421.56840.ftm.van.vugt@foxi.nl>

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.Kraaijeveld@Askesis.nl
web: www.askesis.nl 





view thread (4+ messages)

Message-ID: <1128518380.3655.226.camel@Panoramix>
Permalink:  ../1128518380.3655.226.camel@Panoramix/
Also on:    postgresql.org/message-id/1128518380.3655.226.camel@Panoramix

 · 

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: J.Kraaijeveld@Askesis.nl, ftm.van.vugt@foxi.nl
  Subject: Re: Help with simple SQL query?
  In-Reply-To: <1128518380.3655.226.camel@Panoramix>

* 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