取出每个分类的TOP 10,现提供一种比较方便的方法。

 

示例数据库:AdventureWorks


比如:取出每个商品分类中最近发布的10条记录

 

 1 use adventureworks

2 go
3 select * from
4 (
5 SELECT ROW_NUMBER() OVER (PARTITION BY ProductSubcategoryID ORDER BY ModifiedDate DESCAS RowNumber,ProductID,Name,ProductSubcategoryID,ModifiedDate FROM Production.Product WHERE ProductSubcategoryID IS NOT NULL
6 ) t
7  where rownumber <=10

 

相关文章:

  • 2022-12-23
  • 2021-08-15
  • 2022-01-01
猜你喜欢
  • 2022-01-02
  • 2022-02-18
  • 2021-08-19
  • 2021-10-19
  • 2022-01-13
  • 2022-12-23
相关资源
相似解决方案