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 网络编程(一)
网络通讯要素 IP地址(InetAddress) 端口号 传输协议 图示: TDP/IP模型 以OSI 7层模型讲解数据的传输 InetAddress InetAddress类主要表示IP地址. ...
- WebSocket API简介
WebSocket是html5新增加的一种通信协议,目前流行的浏览器都支持这个协议,例如Chrome,Safari,Firefox,Opera,IE等等,对该协议支持最早的应该是chrome,从chr ...
- mysql使用过程中碰到的问题
start job failed to start mysql ubuntu 原因时我将var整个目录的组权限设置为www-data了, 试了网上的办法都不行(有个妥协方法是重新安装, 但很不好), ...
- mq_setattr
NAME mq_setattr - 设置消息队列的属性(REALTIME) SYNOPSIS #include <mqueue.h> int mq_setattr(mqd_t mqdes, ...
- 291. Word Pattern II
题目: Given a pattern and a string str, find if str follows the same pattern. Here follow means a full ...
- 266. Palindrome Permutation
题目: Given a string, determine if a permutation of the string could form a palindrome. For example,&q ...
- Android百度地图开发02之添加覆盖物 + 地理编码和反地理编码
下面来看一下地图上覆盖物的添加,以及地理编码和反地理编码. 添加覆盖物 在地图上添加覆盖物,一般需要以下几个步骤: 1. 定义坐标点,有可能是一个,有可能是多个(比如:多边形覆盖物). 2. 构造Ov ...
- [转]设置控件全局显示样式appearance proxy
转自:huifeidexin_1的专栏 appearance是apple在iOS5.0上加的一个协议,它让程序员可以很轻松地改变某控件的全局样式(背景) @selector(appearance) 支 ...
- 关于MySQL
DBMS - 数据库管理系统(Database Management System) RDBMS - 关系数据库管理系统(Relational Database Management System) ...
- thrift 安装介绍
一.About thrift thrift是一种可伸缩的跨语言服务的发展软件框架.它结合了功能强大的软件堆栈的代码生成引擎,以建设服务,工作效率和无缝地与C + +,C#,Ja ...