答案 0 :(得分:1)
您可以使用lag()
:
select t.id,
coalesce(nullif(date, '01-01-1900'),
lag(date) over (order by id)
) as date
from t;
编辑:
如果要更新值,请使用可更新的CTE:
with toupdate as (
select t.*, lag(date) over (order by id) as prev_date
from t
)
update toupdate
set date = prev_date
where date = '1900-01-01';