Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL Statement Question

Re: SQL Statement Question

From: Alex Filonov <afilonov_at_pro-ns.net>
Date: Fri, 26 Jan 2001 17:25:11 GMT
Message-ID: <94sbtb$1ha$1@nnrp1.deja.com>

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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US