按顺序索引编辑多行 [英] Editing Multiple Rows by Their Order Index
本文介绍了按顺序索引编辑多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问:我将如何使用/应用查询中每一行的行号到整个查询中的特定列?
Q: How would I go about using / applying the row number of each row in a query to a certain column in the entire query?
我添加了一个屏幕截图,试图让事情变得更明显:
I've added a screenshot to try and make things more obvious:
[图片只是一个简单的例子]
[The picture is only a simple example]
我希望能够在这样的上下文中直接使用行号的值.(以某种方式迭代这些值?)
I would like to be able to directly use the value of the row number in such a context. (Iterate over the values, somehow?)
提前致谢.(如果问题有点含糊,请见谅)
Thanks in advance. (Sorry if the question is a bit vague)
推荐答案
试试这个:
;WITH TEST AS
(
SELECT *,
ROW_NUMBER() OVER (ORDER BY id DESC) AS RowNo
FROM [UserTable]
)
UPDATE TEST
SET myindex = RowNo
这篇关于按顺序索引编辑多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文