I have a PostgreSQL table that contains the following structure:
Parent child1 child2
1 10 12
2 13
3
I want to have:
Parent child1 child2
1 10 12
2 13 13
3 3 3
I mean, if child2 is NULL, I want to duplicate child1 into child2; and if child1 is null, I want to duplicate the parent into child1 and child2.
COALESCE(child2,child1,parent) AS child2