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所有功能结构中的大多数,包括指令,服务,控制器,资源以及其它内容.但是我们知道有时候仅仅阅读是不够的. ...
随机推荐
- HDU 1558 Segment set (并查集+线段非规范相交)
题目链接 题意 : 如果两个线段相交就属于同一集合,查询某条线段所属集合有多少线段,输出. 思路 : 先判断与其他线段是否相交,然后合并. #include <cstdio> #inclu ...
- hdu 1404/zoj 2725 Digital Deletions 博弈论
暴力打表!! 代码如下: #include<iostream> #include<algorithm> #include<cstdio> #include<c ...
- Understanding node.js
Node.js has generally caused two reactions in people I've introduced it to. Basically people either ...
- php截取字符串中的关键字,并高亮显示
<?php $str = "hahaceshi测试一下关键字高亮显示,以及长字符串截取的问题!"; $key = "关键字"; $r = sub_key_ ...
- Spring框架学习之第2节
传统的方法和使用spring的方法 使用spring,没有new对象,我们把创建对象的任务交给了spring的框架,通过配置用时get一下就行. 项目结构 applicationContext.xml ...
- Qt 显示图片 放大 缩小 移动(都是QT直接提供的功能)
本文章原创于www.yafeilinux.com 转载请注明出处. 现在我们来实现在窗口上显示图片,并学习怎样将图片进行平移,缩放,旋转和扭曲.这里我们是利用QPixmap类来实现图片显示的. 一.利 ...
- Java笔记——JavaMail发送邮件
1.JavaMail概述 Java Mail是由SUN公司提供的专门针对邮件的API,主要Jar包:mail.jar.activation.jar. ======================== ...
- http://www.ibm.com/developerworks/cn/java/j-lo-junit-src/
http://www.ibm.com/developerworks/cn/java/j-lo-junit-src/
- Android 仿微信小视频录制
Android 仿微信小视频录制 WechatShortVideo和WechatShortVideo文章
- Java日期转换SimpleDateFormat格式大全(转)
24小时制时间显示: public class Datetime { public static void main(String args[]){ java.util.Date current=ne ...