Let us consider message chat
Case
User wanted to get last 100 msg 
When he scroll up again he have to get 100 more like that we have to get data how to write query in SQL Server

Explanation
Let us consider 4 people are there in a group and chatting
Every one last 50 records at least
He can go back again i.e he have to get last 51-100
Then again scrolling means
1001-151