Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: SQL Statement Question
In article <94r9o6$ee9$01$1_at_news.t-online.com>,
"Michael G. Schneider" <mgs_at_mgs-software.de> wrote:
> Suppose there is a Customer table containing
> custPk (primary key)
> custName (name)
> and a Order table containing
> ordPk (primary key)
> ordCustomer (reference to Customer)
> ordAmount (amount)
select c.custName, max(c.ordAmount)
from Customer c, Order o
where c.custPk = o.ordCustomer (+)
group by c.custName, c.custPk, o.ordCustomer
>
> Now I would like to select all Customers with their highest order. So
there
> should be exactly one row for each customer. And if that customer has
> orders, only the highest one should be taken.
>
> How would I do this in SQL?
>
> Michael G. Schneider
> mailto:mgs_at_mgs-software.de
>
>
Sent via Deja.com
http://www.deja.com/
Received on Fri Jan 26 2001 - 11:25:11 CST