您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

SQL Server中具有IGNORE NULLS的Last_value

SQL Server中具有IGNORE NULLS的Last_value

您可以通过两个累积操作来执行此操作:

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无法轻松做到这一点,所以我猜想这是没有必要的。

SQLServer 2022/1/1 18:52:56 有421人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶