Two SQL paging query statement sharing

Time:2022-1-2

According to the meaning of the question:

The essence is to write paging query:

Number of entries per page: 10;

Current page: 4;

Copy codeThe code is as follows:
//First:
select * from
 (select ROW_NUMBER() over(order by Id asc) as num,* from UserInfo)as u
 where u.num
 between
 10*(4-1)+1
 and
 10*4
//Second:
select top 10 * from UserInfo
where Id not in
(select top (10*3) id from UserInfo order by Id)
order by Id