天天看點

sqlserver2008 sql使用rownumber分頁

大家好,又見面了,我是你們的朋友全棧君。

@pageSize=2;
@pageIndex=3;
5=(@pageIndex - 1 ) * @pageSize +1;
6= @pageIndex * @pageSize;

SELECT * FROM
(
    SELECT ROW_NUMBER() OVER (ORDER BY cdate ASC) AS 'RowNumber', * FROM tb_push_order_log where 1=1
) AS tb_push_order_log
WHERE RowNumber BETWEEN 5 AND 6;           

複制

select * from (

SELECT
	ROW_NUMBER () OVER (ORDER BY a.oper_date DESC) AS RowNumber,
	a.item_no ItemNo,
    b.item_subno ItemSubno,
	item_name ItemName,
	stock_qty StockQty
FROM
	t_im_branch_stock a
INNER JOIN t_bd_item_info b ON a.item_no = b.item_no
 where a.branch_no = '000001'
)a where  RowNumber between 1 and 100            

複制

釋出者:全棧程式員棧長,轉載請注明出處:https://javaforall.cn/138510.html原文連結:https://javaforall.cn