I have a table say TA where the data looks like,
| ID | SSN | Date |
|---|---|---|
| Null | 123 | 1 |
| Null | 123 | 2 |
| Null | 123 | 3 |
| xyzabc | 123 | 4 |
I want to get one value of ID that is not null and update all the other rows based on that value.
What I have come up with:
UPDATE TA
SET ID = (SELECT DISTINCT ID FROM TA as T1
WHERE TA.SSN= T1.SSN AND T1.ID !=NULL)
WHERE TA.ID=NULL;
I wanted to know the most efficient way to do this as I might be performing this on a table with a large number of rows.