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
===========================================
如果里面的这个表cs_threads数据量超大,比如,几亿条记录,那这个方法应该是有问题的
因为,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 这个语句是把select threadid, ROW_NUMBER() OVER (order by stickydate) as Pos from cs_threads它全部取出来,然后在SQL的外面进行分页的,没在SQL2005上测试过,因为原先在ORACLE上这样的写法是不好的,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
本文由来源 21aspnet,由 javajgs_com 整理编辑,其版权均为 21aspnet 所有,文章内容系作者个人观点,不代表 Java架构师必看 对观点赞同或支持。如需转载,请注明文章来源。