Re: Help with simple SQL query? - Mailing list pgsql-sql

From Frank van Vugt
Subject Re: Help with simple SQL query?
Date
Msg-id 200510051421.56840.ftm.van.vugt@foxi.nl
Whole thread Raw
In response to Re: Help with simple SQL query?  ("Gregory S. Williamson" <gsw@globexplorer.com>)
Responses Re: Help with simple SQL query?  (Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>)
List pgsql-sql
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_pricefrom orderline group by parent_order_id) as foo
where order_id = parent_order_idand order_price != sum_price


This should prove to be as efficient as it gets ;)


-- 
Best,




Frank.


pgsql-sql by date:

Previous
From: "Gregory S. Williamson"
Date:
Subject: Re: Help with simple SQL query?
Next
From: Joost Kraaijeveld
Date:
Subject: Re: Help with simple SQL query?