如何将下一行值更新到当前行 [英] How to update next row value into the current row
本文介绍了如何将下一行值更新到当前行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一张包含以下数据的表格
记录
0
0
2
4
5
6
6
5
4
3
我需要一个新列[Record_Dup],列的值应该是[记录]的下一行值
输出:
记录Record_Dup
0 0
0 2
2 4
4 5
5 6
6 6
6 5
5 4
4 3
3 NULL
如何实现预期结果
解决方案
您可以使用OVER ORDER BY来实现此目的。在这里寻找您的解决方案。
http://blog.sqlauthority.com/2013/09/22/sql- server-how-to-access-previous-row-next-row-value-in-select-statement / [ ^ 一>
I have a table with the following data
Record
0
0
2
4
5
6
6
5
4
3
I need a new column [Record_Dup] and the values for the column should be next row value of the [Record]
Output:
Record Record_Dup
0 0
0 2
2 4
4 5
5 6
6 6
6 5
5 4
4 3
3 NULL
How to acheive the expected result
解决方案
You can achieve this by using OVER ORDER BY. Look here for your solution.
http://blog.sqlauthority.com/2013/09/22/sql-server-how-to-access-the-previous-row-and-next-row-value-in-select-statement/[^]
这篇关于如何将下一行值更新到当前行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文