select top 5 * from Table_1 where Id not in (
select top (5*(2-1)) Id from Table_1 order by Id
)order by Id
使用 not in 数据取反(查询多少条,在第几条后面)
create proc proc_fenye
@PageSize int, --每页多少数据
@PageIndex int, --当前页码
@PageCount int output -- 总页数
as
declare @datacount int -- 数据总条数
select @datacount=count(*) from Table_1
set @PageCount = CEILING(1.0*@datacount/@PageSize)
select * from (
select *,ROW_NUMBER() over(order by Id) as num from Table_1
)as temp where num between @PageSize*(@PageIndex-1)+1 and @PageSize*@PageIndex
使用 row_number进行排序,取间查值
还有两种我不会!