【发布时间】:2020-08-21 07:56:18
【问题描述】:
我正在尝试探索动态更新。
我的实际源表是:
更新后源表的预期结果:
我试过的查询:
WITH t AS
(
SELECT key,
Begin_POS,
Length,
(Begin_POS+ Length) as res
from tab
)
SELECT src_column_id,
Length,res,
COALESCE(Length + lag(res) OVER (ORDER BY src_column_id),1) AS PRE_VS
from t
你能帮助我的方法应该是什么样的吗?
【问题讨论】:
标签: sql sql-server sum azure-sql-database window-functions