funciono, Obrigado. Paulo
________________________________ De: Danilo - InfoCont Sistemas Integrados <[email protected]> Para: Comunidade PostgreSQL Brasileira <[email protected]> Enviadas: Quarta-feira, 26 de Maio de 2010 11:28:27 Assunto: Re: [pgbr-geral] como faço esse update Olá. Não deve ser é a melhor solução, mas... UPDATE test A set j = j + (select max(B.j) from test B where B.J < A.J ) where A.j > (select min(C.j) from test C); Espero ter ajudado. paulo matadr escreveu: > > >create table test(i number , j >number); > >insert into test values(1,2) >insert into test values(1,3) >insert into test values(1,4) > >select * from test; > I J >---------- ---------- > 1 2 > 1 3 > 1 4 >minha intenção: > >depois do update >select * from test; > I J >---------- ---------- > 1 2 > 1 3+2 > 1 4+3 >depois do update >select * from test; > I J >---------- > ---------- > 1 2 > 1 5+2 > 1 7+5 > >Pra oracle >update test x >set x.j = x.j + (select lag_j >from (select i, j, nvl(lag(j) over (order by i,j) ,0) as lag_j >from test) y >where x.i = y.i and x.j = y.j) > >como eu faço isso pra postgres? >Agradeço desde ja > > >Paulo > > > >> > > ________________________________ >_______________________________________________ >pgbr-geral mailing list >[email protected] >https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral -- Danilo Pacheco Martins InfoCont Sistemas Integrados Ltda. Diretor Fone: (47) 3422-3536
_______________________________________________ pgbr-geral mailing list [email protected] https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
