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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding MIN value with group by clause

Status
Not open for further replies.

bmacbmac

IS-IT--Management
Joined
Jan 26, 2006
Messages
392
Location
US
Hi,

I have a table with irecordid, tipartytype, and snamelast. With the following data:

irecordid, tiPartyType, sNameLast
12345 1 EASTON
12345 1 WHS 1A LLC
12345 1 WHS 2B LLC
12345 1 WHS 2C LLC
12345 1 WHS 2D LLC
12345 2 WELLS FARGO BANK

I am trying to find the min(snamelast) for each tipartytype in a record.

I have tried:
Code:
select irecordid, tipartytype, min(snamelast) from mytable
where irecordid = 12345
group by irecordid, tipartytype, snamelast

But, I still get all 6 rows of data. I don't just get the min(snamelast) value for each tirecordtype.

Is there a way to adjust my script to do this?

Using SQL 2000.

Thanks!

Brian
 
remove snamelast from the GROUP BY. It's already covered in an aggregate function.

-------++NO CARRIER++-------
 
Perfect. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top