---分页
declare @page int
declare @size int
set @page=1 --第几页
set @size=2000 --一页多少条
SELECT id FROM
(
select * from zmaction_back where order_id in (
SELECT B.order_id FROM (
SELECT order_id,
(SELECT CAST(order_status as varchar)+',' FROM [dbo].[zmaction_back]
WHERE order_id=A.order_id
order by order_status desc
FOR XML PATH('')) AS order_status_list
FROM [dbo].[zmaction_back] A
GROUP BY order_id
) B where order_status_list='8,'
)
)a
ORDER BY a.id desc OFFSET (@page-1)*@size ROWS FETCH NEXT @size ROWS ONLY
--- 分页 OFFSET (@page-1)*@size ROWS FETCH NEXT @size ROWS ONLY