Try this one:
update (
select c1.valor, x.tot_cap
from OBM2019.compproj c1
inner join (
select chave_projecto, ascendente a, sum(valor) tot_cap
from OBM2019.compproj
where chave_projecto = '1'
group by chave_projecto,ascendente
) x on c1.chave_projecto = x.chave_projecto
where c1.chave_projecto = '1' and c1.numero = x.a
)
SET valor = tot_cap;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…