I have a table with 500,000+ rows and the following columns:
Symbol, ExternalCode, ExternalCodeType, StartDate
Symbol should be unique but it’s not.
There are a handful of rows (~60) that have the same value for Symbol but have a different ExternalCode+StartDate pair.
I want to create a table of uniques so that, when there are multiple entries for the same Symbol, I only take the one with the most recent StartDate.
Is there a simple/elegant way to do this?
In SQL-Server this can be solved without JOINing.
Try this:
The ROW_NUMBER function starts a new series of ‘ID’s ordered by date (so that the latest always equals 1) and partitioned by Symbol, so that each symbol has it’s own set of IDs.
Hope the answer is clear.