How do successive changes define version validity intervals?

LEAD retrieves a later row. The next version's start can close the current version's half-open interval.

SQLite example and interpretation

A loads at second three and B at second eight, giving A the interval [3,8). For the last row distinguish an open-ended version from the end of observation.

WITH r(t,v) AS (VALUES(3,'A'),(8,'B')) SELECT v,t,lead(t) OVER(ORDER BY t) FROM r ORDER BY t;

Result [["A", 3, 8], ["B", 8, null]]

中文

版本生效区间如何从下一次变更推导?

LEAD 读取后续行的值。下一版本的起始时刻可作为当前版本半开区间的终点。

SQLite 示例与适用条件

第 3 秒加载 A,第 8 秒加载 B,A 的区间为 [3,8)。末项没有下一时间,报表需明确是仍有效还是观察结束。

WITH r(t,v) AS (VALUES(3,'A'),(8,'B')) SELECT v,t,lead(t) OVER(ORDER BY t) FROM r ORDER BY t;

结果 [["A", 3, 8], ["B", 8, null]]

References / 参考来源

Keep reading / 继续阅读