Pagination using over Window Function

Source: Internet
Author: User

In SQL Server, there are also many paging methods using SQL. Today we want to summarize the over window function introduced in SQL Server 2005, and then the window function is used for paging.

The sample code is as follows:

-- Set the database context use tsqlfundamentals2008; go -- use row_number paging to find the 1-10 data records select T. custid, T. companyName, T. address, T. city from (select row_number () over (order by custid) as rownum, custid, companyName, address, city from sales. customers) as twhere T. rownum between 1 and 10

Query results:

Output 1st to 10th records.

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.