select threadid from 
(
select threadid, row_number() over (order by stickydate) as pos from cs_threads
) as t 
where t.pos > 100000 and t.pos < 100030
===========================================
如果里面的這個(gè)表cs_threads數(shù)據(jù)量超大,比如,幾億條記錄,那這個(gè)方法應(yīng)該是有問(wèn)題的
因?yàn)椋瑂elect threadid from 
( 
select threadid, row_number() over (order by stickydate) as pos from cs_threads 
) as t 
where t.pos > 100000 and t.pos < 100030 
這個(gè)語(yǔ)句是把select threadid, row_number() over (order by stickydate) as pos from cs_threads它全部取出來(lái),然后在sql的外面進(jìn)行分頁(yè)的,沒(méi)在sql2005上測(cè)試過(guò),因?yàn)樵仍趏racle上這樣的寫法是不好的,oracle中這樣寫比較好:select threadid from 
( 
select threadid, row_number() over (order by stickydate) as pos from cs_threads a where a.pos<100030 
) as t 
where t.pos > 100000 
 
新聞熱點(diǎn)
疑難解答
圖片精選