我正在使用此查询以分页方式获取结果。但是,当我尝试执行它时,我收到Invalid column name 'RowNum'
DECLARE @PageNum AS INT;
DECLARE @PageSize AS INT;
SET @PageNum = 2;
SET @PageSize = 10;
WITH videosrn AS
(
SELECT ROW_NUMBER() OVER(ORDER BY videoid) AS RowNum
,videoid
,title
FROM videos
)
SELECT * FROM videos
WHERE RowNum BETWEEN (@PageNum - 1) * @PageSize + 1 AND @PageNum * @PageSize
ORDER BY videoid
这里有什么问题?
答案 0 :(得分:4)
您需要select * from videosrn
(不是videos
)
答案 1 :(得分:1)
RowNum是Oracle中的隐式计算列。使用其他名称。