--定义一些参数 declare @nodeId int,@ekid int ,@ecid int,@eid int,@pid int set @nodeId= 1 set @ekid = 7 set @ecid = 2 set @eid = 194 set @pid = 612 --列表 SELECT * FROM ( SELECT *,ROW_NUMBER() OVER(ORDER BY ReleaseTime DESC) AS rowNum FROM dbo.ViewExamProjectDetail WHERE Status = 1 AND nodeid = @nodeId AND EKID = @ekid AND ECID = @ecid and eid=@eid ) AS t WHERE t.rowNum BETWEEN 1 AND 100 --上一篇 SELECT TOP 1 * FROM ( SELECT *,ROW_NUMBER() OVER(ORDER BY ReleaseTime ASC) AS rowNum FROM dbo.ViewExamProjectDetail WHERE Status = 1 AND nodeid = @nodeId AND EKID = @ekid AND ECID = @ecid and eid=@eid ) AS t WHERE t.ID>@pid --下一篇 SELECT TOP 1 * FROM ( SELECT *,ROW_NUMBER() OVER(ORDER BY ReleaseTime DESC) AS rowNum FROM dbo.ViewExamProjectDetail WHERE Status = 1 AND nodeid = @nodeId AND EKID = @ekid AND ECID = @ecid and eid=@eid ) AS t WHERE t.ID < @pid