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