i have these columns as an example:
ID Line Mod2, Mod3, Mod4
1 1 59
1 2 59
Here is the result from the SQL script below:
ID LINE # MOD1 MOD2 MOD3 MOD4
A1 1 59 59
A1 2 59 59
Line 1: I need to move the value in Mod3 to Mod2 (if Mod2 is blank) and remove the value in Mod3 - only if the move has happened
same if there is a value in Mod4 (if Mod2 and Mod3 are blank), then move Mod4 to Mod2 and remove value from Mod4
Here is SQL script
SELECT ID, LINE,
CASE WHEN MOD2 = '' THEN COALESCE(MOD3, MOD4) ELSE MOD2 END as MOD2,
CASE WHEN MOD3 = '' THEN MOD4 ELSE MOD3 END as MOD3 ,
MOD4 = ''
FROM
Open in new window
I actually need to change this to an update statement ...created the SQL select to view the results
If anyone can help out, please let me know. Thank you