Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Help with SQL statement, please!
"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