Sql server 2005带来的分页便利
作者:互联网
2009-05-31
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
出处:blog.joycode.com/dotey/archive/2006/01/16/70493.aspx
相关推荐
专题
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
最新数据
相关文章
分库分表不是银弹!中间表,二次分库分表,ES中间件结合
面试准备之SQL 6 —— 存储过程
面试准备之SQL 5 —— 事务、索引和视图
面试准备之SQL 4—— 数据查询
面试准备之SQL 3——数据管理
面试准备之SQL 2——数据库的实现(T-SQL建库建表)
面试准备之SQL 1——数据库设计
TFS2008SP1, 升级数据库从SQL2005SP3到SQL2008SP1
安装 SQL SERVER MsiGetProductInfo 无法检索 Product Code 解决方案
数据库组件 Hxj.Data
AI精选
