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: Matt B. <mcb_at_fightspam.sd.znet.com>
Date: 2000/06/30
Message-ID: <slpcbqpsjev115@corp.supernews.com>#1/1

"Newbie (Joe )" <jranseth_at_hotmail.com> wrote in message 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:
>
> --

Hmmmm...you don't have much. :-)

Try (assume table is "purchases" with "customer_code" and "sale_amount" columns):

select customer_code, max(sale_amount)
from purchases
group by customer_code;

-Matt Received on Fri Jun 30 2000 - 00:00:00 CDT

Original text of this message

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