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

Pulling Distinct Values Using Two Fields

Status
Not open for further replies.

laina222

Technical User
Sep 7, 2001
172
US
I have a table that has three fields worth noting for the query I need to run. The first is ID#, the second is sequence, and the third is description. What I need to pull is any ID#s where the description is different from sequence to sequence. For example:

ID Sequence Description
520001 1 Bob
520001 2 Bob
520001 3 Charlie

For ID#520001 I would want to retain sequence 1 and 3, or 2 and 3, but not 1, 2, and 3 and most certainly not 1 and 2!

Does anyone know how I could go about doing this? Thanks for any help in advance!
 
Something like this ?
SELECT ID, Min(Sequence) As Seq, Description
FROM yourTable
GROUP BY ID, Description
ORDER BY 1, 2;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top