分页查询
DECLARE @beginId int DECLARE @endId int SET @beginId = 53 set @endId=65 use AffiliatesB2BDB ;WITH AllResult (number,allianceorderDataID) AS ( select row_number()over(order by OrderDate desc) as number ,allianceorderDataID from dbo.Alliance_Order_data(nolock) WHERE AllianceID=1 and OrderDate >='2012-11-26 00:00:00' and OrderDate <='2013-11-25 23:59:59' ) SELECT b.OrderID,b.SID,b.Ouid,b.OrderStatus,b.BrandID,b.Prdtype,b.IfTelBill ,b.num,b.Amount,b.validAmount ,b.rate,b.commission ,b.OrderDate,b.Etd,b.ReturnDate,b.DataChange_CreateTime,b.DataChange_LastTime FROM AllResult a INNER JOIN Alliance_Order_data(nolock) b ON a.allianceorderDataID=b.allianceorderDataID WHERE a.number>=@beginId AND a.number<=@endId
// WHERE a.number>(@pagesize*(@pageindex-1))
// AND a.number<=@pagesize*@pageindex";