試出了下面的方式, 所以記錄一下
[Oracle DB]
PageSize就是一頁的資料筆數
如果希望一頁有10筆資料, PageSize 就代入10
SELECT *
FROM (
SELECT
FLOOR((ROWNUM-1)/PageSize)+1 AS PAGE
,A.*
FROM OracleTable AS A
)
WHERE PAGE = 1
FROM (
SELECT
FLOOR((ROWNUM-1)/PageSize)+1 AS PAGE
,A.*
FROM OracleTable AS A
)
WHERE PAGE = 1
[SQL Server 2005]
UpdateDate是用來排序列出資料編號的欄位
PageSize就是一頁的資料筆數
如果希望一頁有20筆資料, PageSize 就代入20
SELECT *
FROM (
SELECT
(ROW_NUMBER() OVER (ORDER BY UpdateDate)-1)/PageSize+1 AS Page
,A.*
FROM SQLTable AS A
)
WHERE Page = 1
FROM (
SELECT
(ROW_NUMBER() OVER (ORDER BY UpdateDate)-1)/PageSize+1 AS Page
,A.*
FROM SQLTable AS A
)
WHERE Page = 1
沒有留言:
張貼留言