How can I fill in ? or null values in col2 with the corresponding values in col1 using Teradata SQL?
Data
col1 col2
10 10
11 ?
12 12
14 ?
65 ?
Expected Output
col1 col2
10 10
11 11
12 12
14 14
65 65
CodePudding user response:
select c.col1,
case
when c.col2 is null then c.col1
else col2
end as col2
from your_table as c
CodePudding user response:
Use COALESCE
:
SELECT col1, COALESCE(col2, col1) AS col2
FROM yourTable
ORDER BY col1;