I have a table Datawarehouse
which the population went wrong. Each row has a name
and an ID
and for each update in the original system, a new row in the DWH
table is created that should maintain the same ID
and Name
of the affected object.
For some reason there was generation of duplicate IDs
for the same Object (same name, knowing that name is also unique object wise not table wise, same as ID, it is not a table primary key, it is just an object ID).
Knowing that I have the following fields: ID
, Name
, IsLatest
, what I need to do now is to fix the Data. For that the pseudo code I need to use is:
1. Select the list of rows with the same Name
2. Select the ID where IsLatest = 1
3. Update the rest of rows with that ID
I had issue with the update query, I was not able to select only one ID
, and I was not also able to loop on different names.