gpt4 book ai didi

sql - TSQL - 无效的列名行号

转载 作者:行者123 更新时间:2023-12-02 07:31:08 25 4
gpt4 key购买 nike

为什么显示'Invalid Column Name'对于 WHERE 中的 RowNumber .

SELECT Id, Name,
ROW_NUMBER() OVER (ORDER BY Id) AS 'RowNumber'
FROM Folks
WHERE RowNumber=3

While 可以与 ORDER BY 一起使用

SELECT Id, Name
ROW_NUMBER() OVER (ORDER BY Id) AS 'RowNumber'
FROM Folks
ORDER BY RowNumber DESC

最佳答案

试试这个:

SELECT  *
FROM (SELECT Id, Name,
ROW_NUMBER() OVER (ORDER BY Id) AS 'RowNumber'
FROM Folks
) AS A
WHERE RowNumber = 3

关于sql - TSQL - 无效的列名行号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24963288/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com