Thank you for this post. The last block of code wont run for me in snowflake . I changed ON to WHERE.
UPDATE ToTable as t2
set val = r.total
from (
select ID,
sum(HiddenCash) + sum(Cash) + sum(income) as total
from SourceTable
group by ID
) as r
on t2.ID= r.ID;
UPDATE ToTable as t2
set val = r.total
from (
select ID,
sum(HiddenCash) + sum(Cash) + sum(income) as total
from SourceTable
group by ID
) as r
where t2.ID= r.ID;