I have the following table structure:
CREATE TABLE perf
(
startDate DATE,
performance DOUBLE PRECISION,
indexLevel DOUBLE PRECISION
PRIMARY KEY (startDate)
);
The columns startDate and performance are filled in a previous step. Now I want to set the indexLevel in a time-efficient way. In MSSQL this was done like:
SET @Index = 100;
UPDATE perf SET @Index = @Index * (1+performance), indexLevel = @Index;
How could this be implemented in PostgreSQL?
Is there a better solution than iterating through the table like here: Iterate through table, perform calculation on each row