'group by cols but with a value

Question on the sql, any help is appreciated

dataset:

a_col    b_col
1        null 
null     1 
2        null 
null     2 

expected output

a_col   b_col    group_by_ 
1       null     1
null    1        1
2       null     2
null    2        2


Sources

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

Source: Stack Overflow

Solution Source