If I have a table named [Part] with columns [PartID],[IDNumber], and [Length] and data:
[PartID] [IDNumber] [Length]
1 Test1 50
2 Test1 60
3 Test2 50
4 Test3 70
How can I select just the top 2 records with a distinct IDNumber? After searching for a bit I have not been able to find a query that does what I want. I would like the results to look like this:
[PartID] [IDNumber] [Length]
1 Test1 50
3 Test2 50
What I have now:
Select distinct top 2
[PartID],
[IDNumber],
[Length]
from
[Part]
To clarify that the PartID is actually a GUID. I thought writing out the GUID for each record was getting a bit messing in my example data.
1 Answer