您可以通过两个累积操作来执行此操作:
select t.*,
coalesce(score, max(score) over (partition by maxid)) as newscore
from (select t.*,
max(case when score is not null then id end) over (order by id) as maxid
from t
) t;
最里面的子查询获取有值的最新ID。最外层的那个值“扩展”到随后的行。
如果您确实要更新表格,则可以轻松地将其合并到中update
。但是,Oracle无法轻松做到这一点,所以我猜想这是没有必要的。