📜  从 postgresql 代码示例中的上一行中选择值

📅  最后修改于: 2022-03-11 15:04:50.893000             🧑  作者: Mango

代码示例1
-- use LAG(column_name, lag) OVER (PARTITION BY x ORDER BY y)
select
    id,
    version,
    start_date,
    lag(dss_end_date, 1) over (partition by id order by version) as previous_row_end_date
    end_date
from
    table
order by
    id,
    version;