Answer the question
In order to leave comments, you need to log in
How to fill a table cell with the data of another cell?
there is a postgers table
in the 4th column (where there are asterisks), if the line in column No. 3 is equal to “minus”, write data = column02 of this line - column02 of the next line ( c = ab)
How to do it
Answer the question
In order to leave comments, you need to log in
Wrote a script on nodejs, went through a loop and everything is ok
In SQL Server, this is done using the LEAD () window function, PostgreSQL seems to have this too :
UPDATE table_name SET column4 = CASE
when column4 = 'minus' then column2 - lead(column2) OVER (ORDER BY id)
else column4
END
I would dig in the direction of the Cursors. I can’t sketch out the code right off the bat, but bypassing the cursor involves sequential processing of each line, and there, in theory, you can do what you want.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question