I have a table of people that has a unique primary key for each record. However, due to radical differences in written language, people can appear several times with different spellings of the same name. There is another foreign key field for which each person has a unique value even though the person has more than one record. I cannot use the primary key.
What I need to do is select the most recent record for each person based on the foreign key and the date that the record was modified. A TOP 1 clause would return just one record. What I need is a select statement that returns the TOP 1 for each person in the table. I could do this with a cursor, but this is already inside of a cursor - I'd like to avoid nested cursors.
I vaguely remember seeing a solution for this (perhaps even here) but that was a long time ago.
Does anyone know how this is done?
What I need to do is select the most recent record for each person based on the foreign key and the date that the record was modified. A TOP 1 clause would return just one record. What I need is a select statement that returns the TOP 1 for each person in the table. I could do this with a cursor, but this is already inside of a cursor - I'd like to avoid nested cursors.
I vaguely remember seeing a solution for this (perhaps even here) but that was a long time ago.
Does anyone know how this is done?