views:

50

answers:

2

Hi I tried to execute the below query to get results as paging manner
but when i tried to execute i'm getting error like Invalid column name 'RowNum'
can you try it once

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

thanks in advance

+1  A: 

RowNum is an implicit calculated column in Oracle. Use a different name.

tpdi
no actually i'm trying to execute in sql server. any how i changed it to rownum1 but still i'm getting the same problem
Nagu
+3  A: 

You need select * from videosrn (not videos)

Ed Harper
Yes exactly... thank you very much
Nagu