table source id first_value second_value 0 0 0 1 0 1 2 1 0 3 1 1 desired output id value 1 second 2 first 3 first 3 second