T-SQL备忘(4):分页
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):分页的更多相关文章
- DB&SQL备忘
DB2最佳分页语句 SELECT * FROM ( SELECT inner2_.*, ROWNUMBER() OVER(ORDER BY ORDER OF inner2_) AS rownumber ...
- 一些性能查询的SQL 备忘
--检查数据库的等待事件 from v$session_waitwhere event not like 'SQL%' and event not like 'rdbms%' --找出系统中耗时的操作 ...
- sql 备忘
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual; select dbms_metadata.get_ddl('TABLE','TAB ...
- Sql 备忘——行号
SELECT row_number() over(order by Product.ID) as [row_number]
- 2019-07-06 sql备忘 连续取最大
连续最大: SELECT M.* FROM #temp MINNER JOIN (SELECT ISNULL(A.score,0)-b.score AS score,B.id FROM #temp A ...
- Mysql又一次整理笔记--woods备忘
==============================SQL备忘 CRUD 查询 多表 事件等=============================== ------------------ ...
- SQL Server修改标识列方法(备忘)
原文:SQL Server修改标识列方法(备忘) SQL Server修改标识列方法 ----允许对系统表进行更新 exec sp_configure 'allow updates',1 reconf ...
- Nmap备忘单:从探索到漏洞利用(Part 4)
这是我们的Nmap备忘单的第四部分(Part 1. Part 2. Part 3).本文中我们将讨论更多东西关于扫描防火墙,IDS / IPS 逃逸,Web服务器渗透测试等.在此之前,我们应该了解一下 ...
- AngularJS之备忘与诀窍
译自:<angularjs> 备忘与诀窍 目前为止,之前的章节已经覆盖了Angular所有功能结构中的大多数,包括指令,服务,控制器,资源以及其它内容.但是我们知道有时候仅仅阅读是不够的. ...
随机推荐
- Java集合框架(一)
Java中集合类的关系图: Collection 先来集合中的最大接口——Collection 可以通过查看JDK帮助文档,了解Collection接口中的最共性的方法.通过以下代码示例演示这些方法 ...
- lintcode:删除链表中指定元素
题目 删除链表中等于给定值val的所有节点. 样例 给出链表 1->2->3->3->4->5->3, 和 val = 3, 你需要返回删除3之后的链表:1-> ...
- lintcode:线段树的构造
线段树的构造 线段树是一棵二叉树,他的每个节点包含了两个额外的属性start和end用于表示该节点所代表的区间.start和end都是整数,并按照如下的方式赋值: 根节点的 start 和 end 由 ...
- Ubuntu刷新DNS
linux刷新dns的缓存方法是: sudo /etc/init.d/nscd restart 如果发现提示命令找不到: sudo: /etc/init.d/nscd: command not fou ...
- nodpad++正则替换
则表达式是一个查询的字符串,它包含一般的字符和一些特殊的字符,特殊字符可以扩展查找字符串的能力,正则表达式在查找和替换字符串的作用不可忽视,它 能很好提高工作效率. EditPlus的查找,替换,文件 ...
- nginx添加nginx_mod_h264_streaming-2.2.7模块编译报错
报错ngx_http_streaming_module.c:158: 错误:‘ngx_http_request_t’ 没有名为 ‘zero_in_uri’ 的成员.这需要修改nginx_mod_h26 ...
- Activity Recognition行为识别
暑假听了computer vision的一个Summer School,里面Jason J. Corso讲了他们运用Low-Mid-High层次结构进行Video Understanding 和 Ac ...
- word2vec——高效word特征提取
继上次分享了经典统计语言模型,最近公众号中有很多做NLP朋友问到了关于word2vec的相关内容, 本文就在这里整理一下做以分享. 本文分为 概括word2vec 相关工作 模型结构 Count-ba ...
- URAL 1097 Square Country 2 离散化
一共才100个正方形,将所有正方形左下角和右上角的X坐标和Y坐标离散化,直接枚举新建公园的点的坐标即可. O(n^3)的时间复杂度. #include <cstdio> #include ...
- dojo 四 类的构造函数和父方法的调用
与java类一样,在Dojo里也可以定义constructor 构造函数,在创建一个实例时可以对需要的属性进行初始化.//定义一个类Mqsy_yj var Mqsy_YJ = declare(null ...