SQL Server queries 31 to 40 records in the table, and writes an SQL statement to output 31 to 40 records in the UserInfo table in case of discontinuous IDS (the database is SQL Server, and the Automatically increasing id is used as the primary key, note that the ID may not be consecutive )? According to the meaning of the question, the essence is to write paging queries: the number of entries per page: 10; the current page number
SQL Server queries records ranging from 31 to 40 in the table, and writes an SQL statement to output 31 to 40 records in the UserInfo table due to inconsistent IDS (the database is SQL Server, the auto-increment ID is used as the primary key. Note that the ID may not be consecutive )? According to the meaning of the question, the essence is to write paging queries: the number of entries per page: 10; the current page number
SqlServerQueryFrom 31 to 40Record,ConsiderationsNo idContinuousOfSituation
Write an SQL statement output table UserInfo Table 31 to 40Record(The database is SQL Server, and the Automatically increasing ID is used as the primary key. Note that the ID may not beContinuous)?
Understanding Based on question:
The essence is to write pages.Query:
Number of entries per page: 10;
Current page number: 4 pages;
1 // first: 2 select * from 3 (select ROW_NUMBER () over (order by Id asc) as num, * from UserInfo) as u 4 where u. num 5 between 6 10 * (4-1) + 1 7 and 8 10*4 9 // type 2: 10 select top 10 * from UserInfo 11 where Id not in12 (select top (10*3) id from UserInfo order by Id) 13 order by Id
View Code