From: Frank van Vugt <ftm.van.vugt@foxi.nl>
To: Joost Kraaijeveld <J.Kraaijeveld@askesis.nl>
Cc: pgsql-sql@postgresql.org
Subject: Re: Help with simple SQL query?
Date: Wed, 5 Oct 2005 14:21:56 +0200
Message-ID: <200510051421.56840.ftm.van.vugt@foxi.nl> (raw)
In-Reply-To: <71E37EF6B7DCC1499CEA0316A2568328024BBA0B@loki.wc.globexplorer.net>
References: <71E37EF6B7DCC1499CEA0316A2568328024BBA0B@loki.wc.globexplorer.net>
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 ;)
--
Best,
Frank.
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: ftm.van.vugt@foxi.nl, J.Kraaijeveld@askesis.nl
Subject: Re: Help with simple SQL query?
In-Reply-To: <200510051421.56840.ftm.van.vugt@foxi.nl>
* 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