【发布时间】:2021-08-01 16:06:36
【问题描述】:
我的表结构如下:
CREATE TABLE perf
(
startDate DATE,
performance DOUBLE PRECISION,
indexLevel DOUBLE PRECISION
PRIMARY KEY (startDate)
);
startDate 和 performance 列是在上一步中填充的。现在我想以一种省时的方式设置indexLevel。在 MSSQL 中,这样做是这样的:
SET @Index = 100;
UPDATE perf SET @Index = @Index * (1+performance), indexLevel = @Index;
这如何在 PostgreSQL 中实现?
有没有比遍历表更好的解决方案:Iterate through table, perform calculation on each row
【问题讨论】:
-
请提供样本数据和所需结果。
标签: sql postgresql performance sql-update