From: | Joost Kraaijeveld <J(dot)Kraaijeveld(at)Askesis(dot)nl> |
---|---|
To: | "Pgsql-sql(at)postgresql(dot)org" <Pgsql-sql(at)postgresql(dot)org> |
Subject: | Help with simple SQL query? |
Date: | 2005-10-05 11:35:32 |
Message-ID: | 1128512132.3655.200.camel@Panoramix |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi,
I have 2 tables with the following columns:
order: order_id, order_price
orderline: parent_order_id, orderline_price
I want all orders order where _price <> sum(orderline_price).
What is wrong with the following query:
select order_id from order, orderline
where order_id = parent_order_id
and order_price <> (select sum(orderline_price) from orderline group by
parent_order_id)
It reports "ERROR: more than one row returned by a subquery used as an
expression" which seems right (the select sum() returns multiple rows?),
but I cannot get query right. Can someone help?
TIA
--
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 | Gregory S. Williamson | 2005-10-05 11:47:17 | Re: Help with simple SQL query? |
Previous Message | Richard Huxton | 2005-10-05 08:32:31 | Re: Getting user created tables from SQL |