Getting only top one most recent unique row
Posted on 2013-06-21
I want to return the top most recent row containing a distinct modId, eliminating the duplicates.
I have a table:
Notice the id is the unique id field of the table.
But the Modid can have multiple rows. I want to sort by the Id field descending in order to get the most recent row (yes, there is more data per row not included) and exclude the duplicate modids.
So my return results should be:
8,7,5,3,2 and the less recent duplicate rows will not be included.
I only need to return the Id field, not the modId field if that helps, because my final query can include
select * from mytable where id IN (select id from yourquery)
How would I do that?