当前位置:Gxlcms > 数据库问题 > 步步为营-46-分页显示的SQL语句

步步为营-46-分页显示的SQL语句

时间:2021-07-01 10:21:17 帮助过:23人阅读

--每页n条,选择第m页--n=2 m=3 --select top(n) * fromwhere 主键 not in (select top(m-1)*n 主键 from 表); select * from UserInfo select top(2) * from UserInfo where Empid not in (select top((3-1)*2) EmpId from UserInfo); --方法二,通过rowNumber函数,但是只能当作临时表 select * from(select * ,ROW_NUMBER() over (order by EmpId) as num from UserInfo) as T where T.num between (3-1)*2+1 and 3*2; --over开窗函数的的另一个用法 select top(2) * ,AVG(StuAge) over() as 平均年龄 from UserInfo; View Code

技术分享

 

步步为营-46-分页显示的SQL语句

标签:one   use   select   ide   sql   分页   where   lock   hid   

人气教程排行