窗口函数和 NEXT VALUE FOR 函数不支持常量作为 ORDER BY 子句表达式

Flo*_*Flo 4 t-sql sql-server pagination sql-order-by

运行此语句时出现错误 Windowed functions and NEXT VALUE FOR functions do not support constants as ORDER BY clause expressions.

SELECT * FROM (select ROW_NUMBER() OVER (ORDER BY 'publishdate DESC') as RowNum,
* FROM news WHERE publishdate <=getdate()) as info
WHERE RowNum > 0 AND RowNum <= (100)
Run Code Online (Sandbox Code Playgroud)

我想使用此语句在分页网格视图中检索结果集。

如何让这个语句运行?

M.A*_*Ali 5

SELECT * FROM (select ROW_NUMBER() OVER (ORDER BY publishdate DESC) as RowNum,
* FROM news WHERE publishdate <=getdate()) as info
WHERE RowNum > 0 AND RowNum <= (100)
Run Code Online (Sandbox Code Playgroud)

您不需要'in (ORDER BY publishdate DESC)