SQL Server is proficient in----3 types of pagination from getting started

Source: Internet
Author: User

--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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.