Requires Free Membership to View
The ROW_NUMBER function returns the ordinal row position of each row in a grouping within a result set. This function can be very useful for generating reports.
select ROW_NUMBER() over(PARTITION BY PC.Name ORDER BY ListPrice) as Row, PC.Name Category, P.Name Product, P.ListPrice From Production.Product P JOIN Production.ProductSubcategory PSC on P.ProductSubCategoryID = PSC.ProductSubCategoryID JOIN Production.ProductCategory PC on PSC.ProductCategoryID = PC.ProductCategoryID
This was first published in June 2006

Join the conversationComment
Share
Comments
Results
Contribute to the conversation