test=# create table firefall (id int, col1 text, col2 text);
CREATE TABLE
Time: 4,642 ms
test=*# insert into firefall values (1, 'col1_1','col1_2');
INSERT 0 1
Time: 0,387 ms
test=*# insert into firefall values (2, 'col2_2',NULL);
INSERT 0 1
Time: 0,194 ms
test=*# select * from firefall ;
id | col1 | col2
----+--------+--------
1 | col1_1 | col1_2
2 | col2_2 |
(2 rows)
Time: 0,261 ms
test=*# select id, col1, coalesce(col2,col1) from firefall ;
id | col1 | coalesce
----+--------+----------
1 | col1_1 | col1_2
2 | col2_2 | col2_2
(2 rows)
Time: 0,248 ms