sql分页demo

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql分页demo相关的知识,希望对你有一定的参考价值。

ALTER proc [dbo].[ProcGetUserInfoPageInfoByUserName]
    @UserName varchar(200),
    @PageIndex int,    
    @PageSize int
as
Begin    
    select Row_Number()over(order by UserID)as RowNumber, UserID, UserName, 
    Mobile, WeixinID, Unit, IsReturnReceipt,‘‘ as RegionMap,IsPSUser,UserCode 
    into #Main
    from dbo.UserInfo
    where UserName like %+@UserName+% and Status=0
    
    select  UserID, UserName, Mobile, WeixinID, Unit, IsReturnReceipt, RegionMap,IsPSUser,UserCode ,(select count(1) as TotalCount from #Main) as TotalCount
    from #Main
    where RowNumber between (@PageIndex-1)*@PageSize+1 and @PageIndex*@PageSize 
    
End


sql语句
  select * from (
  select *,(select count(*) from t_approval_baseinfo) as TotalCount,Row_Number()over(order by reciev_time desc) as RowNumber
  from t_approval_baseinfo) rds
  where rds.RowNumber between (1-1)*10 +1 and 1*10

 








以上是关于sql分页demo的主要内容,如果未能解决你的问题,请参考以下文章

sql分页demo

[oracle]pl/sql --分页过程demo

面试常用的代码片段

springmvc 分页查询的简单实现

MyBatis动态SQL标签用法

分页后台代码Demo