SQLServer(SQL的各種常用算法問題)
實現分頁,可以使用嵌套查詢,也可以使用存儲過程。不過存儲過程太複襍,執行傚率也不一定高, 所以考試大就用這樣的嵌套語句來實現:
SELECT 頁大小 * FROM TestTable
WHERE (ID >(SELECT MAX(id) FROM (SELECT 頁大小*頁數 id FROM TestTable ORDER BY id) AS T)) ORDER BY ID
select * from (select * from scott.emp order by scott.emp.empno) where rownum
0條評論