sqlserver 分页

2021/7/14 19:13:55

本文主要是介绍sqlserver 分页,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

---分页

 

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



这篇关于sqlserver 分页的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程