|
I am trying to remove duplicates from a table. Not all the students have duplicates though. I will provide 2 scenarios below: Any sugestions? I am using this query but it just removes the duplicate ids. I need more logic based on status and year. The first scenario I would want the record that has STATUS = Final AND the most recent YEAR. (This is the 3rd record of id 1) The second scenario since there IS NO Final I just will take the record with the most recent YEAR (This is the second record of id 2)
(comments are locked)
|
|
This example shows how to use I then choose the row number 1's from that data set and I've eliminated the dupes.
(comments are locked)
|
|
You can also use this solution to delete the duplicates: Read more at this question: http://ask.sqlservercentral.com/questions/48287/identify-and-remove-duplicates-help.html
(comments are locked)
|


Just to clarify, what about the scenario
should that give you the 2nd record (as it is a Final) or the 3rd record (as that is from the latest year)?
Initial 2011..Year takes precedence over status