这篇文章主要为大家详细介绍了SQL Server ROW_NUMBER SQL Server 2005的LIMIT功能实现(ROW_NUMBER()排序函数),具有一定的参考价值,可以用来参考一下。
感兴趣的小伙伴,下面一起跟随四海网的小编两巴掌来看看吧!
语法:代码如下:
SELECT * FROM (SELECT ROW_NUMBER() OVER(ORDER BY id ASC) AS rownum, * FROM MyTable) AS items WHERE items.rownum BETWEEN 20 AND 30;
代码如下:
select email,customerID, ROW_NUMBER() over(order by psd) as rows from QT_Customer
代码如下:
select DID,customerID,totalPrice,ROW_NUMBER() over(order by totalPrice) as rows from OP_Order
代码如下:
select ROW_NUMBER() over(partition by customerID order by totalPrice) as rows,customerID,totalPrice, DID from OP_Order
代码如下:
with tabs as
(
select ROW_NUMBER() over(partition by customerID order by totalPrice) as rows,customerID,totalPrice, DID from OP_Order
)
select MAX(rows) as '下单次数',customerID from tabs group by customerID
代码如下:
with tabs as
(
select ROW_NUMBER() over(partition by customerID order by insDT) as rows,customerID,totalPrice, DID from OP_Order
)
select * from tabs
where totalPrice in
(
select MIN(totalPrice)from tabs group by customerID
)
代码如下:
with tabs as
(
select ROW_NUMBER() over(partition by customerID order by insDT) as rows,* from OP_Order
)
select * from tabs where rows = 1
select * from OP_Order
代码如下:
select
ROW_NUMBER() over(partition by customerID order by insDT) as rows,
customerID,totalPrice, DID
from OP_Order where insDT>'2011-07-22'
本文来自:http://www.q1010.com/179/7898-0.html
注:关于SQL Server ROW_NUMBER SQL Server 2005的LIMIT功能实现(ROW_NUMBER()排序函数)的内容就先介绍到这里,更多相关文章的可以留意四海网的其他信息。
关键词:SQL SERVER
四海网收集整理一些常用的php代码,JS代码,数据库mysql等技术文章。