Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MAX RECORD DISPLAY

Status
Not open for further replies.

mbfloyd

Programmer
Apr 28, 2000
22
US
Hi, I am trying to display a max record from multiple tables.
example:
select a.cust_name, a.cust_address, a.cust_num, b.cust_amt, c.cust_cat
from a, b, c
where a.cust_num = b.cust_num
GROUP BY b.cust_amt
order by a.cust_name asc

I am getting all records, but I need the max cust_amt record for each customer.

cust_name cust_num cust_amt cust_cat
ADAM 001 20,000 AGP
ADAM 001 19,500 AGP
EVE 002 5,000 AGP
JOHN 003 11,000 AGP
EVE 002 27,000 AGP


RESULTS NEEDED:
cust_name cust_num cust_amt cust_cat
ADAM 001 20,000 AGP
EVE 002 27,000 AGP
JOHN 003 11,000 AGP

ANY HELP WILL BE APPRECIATED
THANKS
MARQ


 
--This will work

--=============================================
select a.cust_name, a.cust_num, max(b.cust_amt), c.cust_cat
from a, b, c
where a.cust_num = b.cust_num and b.cust_num = c.cust_num
GROUP BY a.cust_name, a.cust_num, c.cust_cat
order by a.cust_name asc

--=============================================
--Shils Jacob Kochumuttom
--=============================================
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top