7.rows_number()可用于分页
思路:先把所有的产品筛选出来,然后对这些产品进行编号。然后在where子句中进行过滤。
8.注意:在使用over等开窗函数时,over里头的分组及排序的执行晚于“where,group by,order by”的执行。
如下代码:
- select
- ROW_NUMBER() over(partition by customerID order by insDT) as rows,
- customerID,totalPrice, DID
- from OP_Order where insDT>‘2011-07-22‘
SQL Server数据库ROW_NUMBER()函数使用详解
标签: