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

Pulling records where Number is same, Sequence and Desc. are different 1

Status
Not open for further replies.

laina222

Technical User
Sep 7, 2001
172
US
I have a table that has data in this format:

ID Number Sequence Desc.
1 1000 1 Cat
2 1000 2 Cat
3 1000 3 Dog
4 1245 1 Mouse
5 1245 2 Mouse
6 1245 3 Mouse
7 1245 4 Mouse
8 1080 1 Rabbit
9 1080 2 Dog
10 1422 1 Lion

The table has a few other fields, but those aren't really important, but do need to be in my results. What I need to know is how to pull all of the Number records where the Description changes within the Number. So for example, in my results, I would need ID#'s 1,3,4,8,9,10. 1 and 3 b/c they are the same Number but the Description changes. 4 because within the Number the description does not change, but the original still needs to be picked up. 8 and 9 because within the Number the description changes from sequence to sequence, and 10 because it stands alone, but like 4, it needs to be picked up.
Any ideas? This is way too complex for me! Thanks for any help in advance :)
 
A starting point:
SELECT A.*
FROM tblSequence AS A INNER JOIN (
SELECT Min(B.ID) AS ID, B.Number, B.Desc
FROM tblSequence AS B GROUP BY B.Number, B.Desc
) AS C ON A.ID = C.ID
ORDER BY 1;

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