The setup is like this:
Col1 Col2
12345 12
12348 14
20145 16
00541 Null
51234 22
Simplified, obviously. What I want to do is update Col2 wherever it's Null by setting it to the Col2 value for whatever has the closest value in Col1 (so in this example, row four should have Col2 set to 12). This is how close I've gotten:
UPDATE Temp.dbo.Sheet4
SET Col2 = (SELECT FIRST(Col2)
FROM Temp.dbo.Sheet4
WHERE Col2 IS NOT NULL
ORDER BY ABS(***Col1 from the outside of this select statement*** - Col1))
WHERE Col2 IS NULL
Probably not that close. But how can I do this? I can't quite get my head around it. I'm also open to doing this in Excel/Access/whatever, but I figured SQL Server would be the easiest.