Вы можете использовать case
выражения:
update tablea
set
col1 = case when col_num = 1 then total end,
col2 = case when col_num = 2 then total end,
col3 = case when col_num = 3 then total end
Возможно, вы добавите некоторые логики c для обновления только ненулевых столбцов
update tablea
set
col1 = case when col1 is null and col_num = 1 then total end,
col2 = case when col2 is null and col_num = 2 then total end,
col3 = case when col3 is null and col_num = 3 then total end
where
(col1 is null and col_num = 1)
or (col2 is null and col_num = 2)
or (col3 is null and col_num = 3)