--Paging Statements--Max ID PagingSelect Top 4 * fromDistrictwhereId>(Select ISNULL(Max(ID),0) from(Select Top 2Id fromDistrictOrder byId) a)--Not ID pagingSelect Top 4 * fromDistrictwhereId not inch(Select Top 2Id fromDistrict)--row_number Sub-pageSelect * from(SelectRow_number () Over(Order byId as Number,* fromDistrict) Awhere Number<=6 and Number>=3--Row_number over explanation--is the number of data to be queried from 1--Grammar OneSelectRow_number () Over(Order byIddesc),* fromDistrict--In the ID descending query in the number, of course go to desc default is ascending--Syntax twoSelectRow_number () Over(Partition byNameOrder byID),* fromDistrict--GROUP by Name column in ascending ID query number--Note: The Group and sort execution level in over is lower than the "Where,group By,order by" execution. ---------is to say that the execution of the outside of the night, in the implementation of the inside, so that will cover the outside group By,order by;--It's best to use the ID Max method for maximum efficiency--of course, you can also use stored procedures for paging, but in contrast, the efficiency is the lowest
SQL Server is proficient in----3 types of pagination from getting started