SQL Paging Query

Source: Internet
Author: User


INSERT INTO info select ' admin36 ' from info; --FK Insertion Method
Select COUNT (*) from Info;

--not in implementing paged query
DECLARE @pageSize int Set @pageSize = number of 10;--rows
DECLARE @pageNo int Set @pageNo = 1000;--pages
Select Top * from Info
where ID not in (
Select Top (@pageSize * (@pageNo-1)) ID from Info
)

--Use the greater than sign > Implement paged Query
DECLARE @pageSize int Set @pageSize = 10; --Number of lines
DECLARE @pageNo int Set @pageNo = 1000; --pages
Select Top (@pageSize) * from Info where ID >
(select Max (ID) from--the maximum value of the first 10 data
(select Top (@pageSize * (@pageNo-1)) ID from Info) as Empinfo)--Query the first 10 data

--use row_num between for paging queries
SELECT * FROM
(select Row_number () over (order by ID) as no,* from Info) as EMP
where emp.no between and 110

SQL Paging Query

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.