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

Home -> Community -> Usenet -> c.d.o.tools -> Re: Help with SQL statement, please!

Re: Help with SQL statement, please!

From: Klaus Zeuch <Klaus.Zeuch_at_t-online.de>
Date: 2000/06/30
Message-ID: <8jiosr$s49$15$1@news.t-online.com>#1/1

Hi,

using a subquery should resolve that problem:

select t1.customer, t1.sales
from sales t1
where t1.sales = (

   select max(sales)
   from sales t2
   where t2.customer = t1.customer);

that might still yield duplicates for customers having more than 1 record with equal top sale. If you want to remove these duplicates, you should query select distinct t1.customer,......

regards

Klaus

"Newbie (Joe )" <jranseth_at_hotmail.com> schrieb im Newsbeitrag news:jg275.334$Hs3.7458_at_news1.mts.net...
> Hello,
> I want to select rows from a table where only one field is
 unique...ie:A
> customer may have several purchases, but I want to return only the biggest
> purchases per customer.
> I currently have it returning all purchases for every customer, but
> would like to see only the max value per customer. Here's what I have:
>
> --
>
>
>
Received on Fri Jun 30 2000 - 00:00:00 CDT

Original text of this message

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