If exists (select * From sysobjects where name = 'webname') Drop table stuwebnamegocreate table stuwebname (stuid int identity (1, 1) primary key, stuname varchar (50) not null, stupassword varchar (50) not null, stusex char (2) default ('male'), stuno int not null) godeclare @ ID intset @ ID = 1 while (@ ID <100) begininsert into stuwebname (stuname, stupassword, stusex, stuno) values ('zhang san' + convert (varchar (50), @ ID), '123', 'mal', 123) set @ ID = @ ID + 1 endgoselect * From stuwebnamego ------------------------------------------------------- the most common sorting types (five pieces of data on each page on the first page) first, use the row_number function to add sequence numbers to each column, and then sort select * from (select row_number () over (order by stuid) as B, * From stuwebname) as awhere B> (2-1) * 5 and B <= 2*5 go -- first query the first 10 rows, then reverse query the first 5 rows, and finally reverse query the data) select * from (select top 5 * from (select top 10 * From stuwebname order by stuid ASC) as t order by stuid DESC) as T order by stuid ascgo -- first query the first six rows, and then obtain the maximum value of stuid select top 5 * From stuwebnamewhere (stuid> = (select max (stuid) from (select top (5*1) + 1) stuidfrom stuwebname order by stuid) as t) order by stuidgo