I am trying to implement paging for a View in T-SQL :
with TH_VW_UserFollowing as
(
Select FollowerID,
FollowingID,
FollowingFullName,
FollowingImage,
FollowingUserName,
dbo.GetUserFollowers(FollowingID) AS Followers,
ROW_NUMBER() OVER (order by dbo.GetUserFollowers(FollowingID) DESC ) AS 'RowNumber'
from dbo.TH_VW_UserFollowing
where FollowerID = @UserID
)
Select FollowerID,
FollowingID,
FollowingFullName,
FollowingImage,
FollowingUserName, Followers
from dbo.TH_VW_UserFollowing
Where RowNumber BETWEEN @startIdx AND @endIdx
for a reason I am getting these errors :
Msg 207, Level 16, State 1, Procedure GetUserUsersFollowing, Line 36
Invalid column name 'RowNumber'.
Msg 207, Level 16, State 1, Procedure GetUserUsersFollowing, Line 36
Invalid column name 'RowNumber'.
Msg 207, Level 16, State 1, Procedure GetUserUsersFollowing, Line 34
Invalid column name 'Followers'.
I've used the same code for a table, but I don't know what is happening here. something is missing...
Thanks.