日期:2014-05-16 浏览次数:20435 次
DECLARE @PageSize int=30,
@PageCount int=1,
@PageTotalCount INT,
@RowCount INT=0
SELECT
@RowCount=COUNT(1)
FROM
ieai_taskconstant con
JOIN ieai_taskruntime run ON con.iid=run.iid
JOIN ieai_flowdef ifl ON con.iflowid=ifl.iid
SELECT @PageTotalCount=CEILING(@RowCount*1.0/@PageSize),@PageCount=CASE WHEN @PageCount>=@PageTotalCount THEN @PageTotalCount ELSE @PageCount END
;WITH f AS
(
SELECT
rows=ROW_NUMBER()OVER(ORDER BY con.istarttime DESC),
con.iid AS id, con.iactname icname, ifl.iflowname ifname,
con.istarttime isname, run.iacquiretime iqname, run.ilastoptime iltime,
run.iowner iower, run.ilastop ilop
FROM
ieai_taskconstant con
JOIN
ieai_taskruntime run ON con.iid=run.iid
JOIN
ieai_flowdef ifl ON con.iflowid=ifl.iid
)
SELECT * FROM f WHERE rows BETWEEN (@PageCount-1)*@PageSize+1 AND @PageCount*@PageSize