I’ve written a query which retrieves top 5 records from a table like this
SELECT Top(5) Activity, GETUTCDATE() as CurrentDate
FROM Activities
WHERE UserID = @uid
ORDER BY ActivityDate DESC
and on View i am displaying top 5 records and i also have a link of More on clicking of which next 5 records should show,again clicking on that link show next 5 records and so on
I am having confusion on how to write this query ie how to get next 5 records then next 5 and so on
I use the RowNumber function and a CTE to achieve paging in your example this would be something like.