set statistics io on
set statistics time on
--SQL Server 2012分页方式
select * from Production.Product
order by ProductID offset 20 row fetch next 10 rows only
--SQL Server 05/08分页方式
go
with cte as
(
select row_number() over(order by productid) as rowNum,* from production.product
)
select * from cte where rowNum>20 and rowNum<=30
--or
select * from (select row_number() over(order by productid) as rowNum,* from production.product) cte
where rowNum>20 and rowNum<=30 --通用方式
select top 10 * from Production.Product where ProductID not in
(
select top 20 ProductID from Production.Product order by ProductID
) order by ProductID select top 10 * from Production.Product where ProductID>
(
select max(ProductID) from (select top 20 ProductID from Production.Product order by ProductID) as temp
) order by ProductID

  

T-SQL备忘(4):分页的更多相关文章

  1. DB&SQL备忘

    DB2最佳分页语句 SELECT * FROM ( SELECT inner2_.*, ROWNUMBER() OVER(ORDER BY ORDER OF inner2_) AS rownumber ...

  2. 一些性能查询的SQL 备忘

    --检查数据库的等待事件 from v$session_waitwhere event not like 'SQL%' and event not like 'rdbms%' --找出系统中耗时的操作 ...

  3. sql 备忘

    select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual; select dbms_metadata.get_ddl('TABLE','TAB ...

  4. Sql 备忘——行号

    SELECT row_number() over(order by Product.ID) as [row_number]

  5. 2019-07-06 sql备忘 连续取最大

    连续最大: SELECT M.* FROM #temp MINNER JOIN (SELECT ISNULL(A.score,0)-b.score AS score,B.id FROM #temp A ...

  6. Mysql又一次整理笔记--woods备忘

    ==============================SQL备忘 CRUD 查询 多表 事件等=============================== ------------------ ...

  7. SQL Server修改标识列方法(备忘)

    原文:SQL Server修改标识列方法(备忘) SQL Server修改标识列方法 ----允许对系统表进行更新 exec sp_configure 'allow updates',1 reconf ...

  8. Nmap备忘单:从探索到漏洞利用(Part 4)

    这是我们的Nmap备忘单的第四部分(Part 1. Part 2. Part 3).本文中我们将讨论更多东西关于扫描防火墙,IDS / IPS 逃逸,Web服务器渗透测试等.在此之前,我们应该了解一下 ...

  9. AngularJS之备忘与诀窍

    译自:<angularjs> 备忘与诀窍 目前为止,之前的章节已经覆盖了Angular所有功能结构中的大多数,包括指令,服务,控制器,资源以及其它内容.但是我们知道有时候仅仅阅读是不够的. ...

随机推荐

  1. (6)妈的终于找到能用的nehe sdk了

    在网上下载了有十多个,终于找到一个能用的了 下面是下载地址: http://download.csdn.net/detail/jason_bourn/681620#comment 泪奔啊~

  2. Struts2 中的值栈的理解

    通过对struts2的一段时间的接触,将自己对OGNL的核心值栈说说,值栈:简单的说,就是存放action的堆栈,当我们提交一个请求 道服务器端 action时,就有个堆栈,如果action在服务器端 ...

  3. MongoDB (六) MongoDB 集合操作

    一. MongoDB 创建集合 createCollection() 方法 MongoDB db.createCollection(name, options) 是用来创建集合. 语法: 基本的 cr ...

  4. hdu 1124 Factorial(数论)

    题意: 求n!的尾0的个数 分析: 0一定是由因子2和5相乘产生的: 2的个数显然大于5的个数,故只需统计因子5的个数 n/5不能完全表示n!中5的个数(egg: 25),应该n/=5后,累加上n/2 ...

  5. 安卓app缓存设置

    无论大型或小型应用,灵活的缓存可以说不仅大大减轻了服务器的压力,而且因为更快速的用户体验而方便了用户. Android的apk可以说是作为小型应用,其中99%的应用并不是需要实时更新的,而且诟病于蜗牛 ...

  6. 学了C语言,如何利用cURL写一个程序验证某个网址的有效性?

    在<C程序设计伴侣>以及这几篇关于cURL的文章中,我们介绍了如何利用cURL写一个下载程序,从网络下载文件.可是当我们在用这个程序下载文件时,又遇到了新问题:如果这个网址是无效的,那么我 ...

  7. MyEclipse快捷键记录

    MyEclipse快捷键 ------------------------------------- MyEclipse 快捷键1(CTRL) ---------------------------- ...

  8. IDL基础

    先列后行 arr=indgen(3,4) SIZE(arr,/dimensions) print ,where(arr gt7) print,arr[where(arr gt 7)] print,wh ...

  9. apache 的ab 工具

    ab是apache 进行http服务器压力测试的一个工具.用来衡量apache 服务器的执行效率,能够检测出apache每秒能够处理的请求数. 一个使用的例子如下(windows下) ab -n -c ...

  10. Highcharts属性详解

    Highcharts的基本属性和方法详解 Highcharts 是一个用纯JavaScript编写的一个图表库, 能够很简单便捷的在web网站或是web应用程序添加有交互性的图表,并且免费提供给个人学 ...