'create new column among multiple columns value

I have a question about how to create a new column based on several column value.

Input:

col1 col2 col3 
1 1 1 
NULL NULL NULL 
2 NULL 2 
NULL NULL 3 
4 NULL NULL 
5 5 NULL 

Output

col1 col2 col3 new
1 1 1 1
NULL NULL NULL NULL
2 NULL 2 2
NULL NULL 3 3
4 NULL NULL 4
5 5 NULL 5

I am trying to use combine_first, but it seems not be a good choice since I have multiple columns need to combine.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source