Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
116 views
in Technique[技术] by (71.8m points)

sql - Why does this statement won't work in ORACLE?

The statement I'm trying to execute in ORACLE:

update c1 
set 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;

Gives error on column 35 "SQL command not properly ended". Thanks.

question from:https://stackoverflow.com/questions/65891640/why-does-this-statement-wont-work-in-oracle

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...