PGSQL 错行,上下行,前后行计算

错两行

select lag(name,-2,'乱七八糟的空替换字符串')  over(order by id) as las,* from sgdd

错行更新当前字段的值

update sgdd set name=z.las from(select lag(name,-2,'乱七八糟的空替换字符串')  over(order by id) as las,* from sgdd) z where z.id=sgdd.id

这个语句之宝贵啊

我搜了好久才回忆起来

猜你喜欢

转载自blog.csdn.net/ccagy/article/details/108223020