基本语句:
SELECT TOP 页大小 *
FROM
(
SELECT ROW_NUMBER() OVER (ORDER BY id) AS RowNumber,* FROM table1
) as A
WHERE RowNumber > 页大小*(页数-1)
实例:
select top 10* from (SELECT ROW_NUMBER() OVER (ORDER BY orderId) AS RowNumber,
orderId,
applyobject,
taskname,
g.taskid,
stuff(
(SELECT ',' + wallname
FROM Order w2
WHERE g.orderid = WallOrderId
FOR xml path ('')),1,1,'') AS stuffName,
beforemoney,
lastmoney,
couponcode,
ispaysuccess,
orderpaytype,
g.createtime,
u.fullname
FROM GOrder g
LEFT JOIN GTasks t ON g.TaskId = t.TaskId
LEFT JOIN GU u ON g.UserId = u.UserId
where g.applyobject=0
GROUP BY g.orderid,
g.applyobject,
t.taskname,
g.taskid,
g.beforemoney,
g.lastmoney,
g.couponcode,
g.ispaysuccess,
g.orderpaytype,
g.createtime,
u.fullname
) dd
where RowNumber > 30 ;