Potatooo
Potatooo

Reputation: 57

How will I remove nulls from each columns

How will I remove nulls from each columns This is the example

Column 1  Column 2 column 3  column 4 
a           1        null      null   
b           0        null      null   
c           1        null      null   
a           null      0        null   
b           null      1        null   
c           null      0        null   
a           null     null       1     
b           null     null       1     
c           null     null       0     

I want it to look like this

Column 1  Column 2 column 3  column 4  
a            1        0         1      
b            0        1         1      
c            1        0         0      

Is this possible? You may see attached pictures for before and after image.

Upvotes: 1

Views: 63

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1271151

You can use aggregation:

select col1, max(col2) as col2, max(col3) as col3, max(col4) as col4
from t
group by col1;

Upvotes: 5

Related Questions