I am developing an application in which am using grid view. I want to use pagination for that grid view by using sql query.

I want to display records with the help of `pagesize` and `pageindex`. 

How can I do this with sql query?