If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > Distinct Recordset by Column Data

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-14-03, 14:00
mdfields mdfields is offline
Registered User
 
Join Date: Oct 2003
Posts: 7
Distinct Recordset by Column Data

I have a current recordset that is retuning like so:

ID Name Number State
1 Matt 1234 IN
1 Matt 1234 TX
2 Jeff 5678 WI
2 Jeff 5678 IL


I want it to return on of the two non-distinct rows but a distinct ID, for instance:

ID Name Number State
1 Matt 1234 IN
2 Jeff 5678 WI

It does not matter which record it returns. Does anyone have an idea
on this?

Thanks
Matt
Reply With Quote
  #2 (permalink)  
Old 10-14-03, 14:51
carloa carloa is offline
Registered User
 
Join Date: Apr 2003
Location: NY
Posts: 208
Re: Distinct Recordset by Column Data

Select a.Id, a.Name, a.Number, a.State
From TABLE a
Where a.State = (Select Max(b.State)
From Table b
Where a.Id = b.Id)


This will return the record where the state is the max for that record.

ID Name Number State
1 Matt 1234 TX
2 Jeff 5678 WI
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On