Posted By

ManuelToledo on 02/16/16


Tagged

sql server rank DENSERANK AdventureWorks


Versions (?)

SQL Server query sample using rank/dense_rank


 / Published in: SQL
 

SQL Server query sample using rank/dense_rank

  1. USE [AdventureWorks2016CTP3]
  2.  
  3. SELECT
  4. [Sales].[SalesOrderHeader].[CustomerID],
  5. count([SalesOrderID]) AS OrdersCount,
  6. DENSE_RANK() OVER (ORDER BY count([SalesOrderID]) DESC) AS Rank
  7.  
  8. FROM
  9. [Sales].[SalesOrderHeader]
  10.  
  11. GROUP BY
  12. [Sales].[SalesOrderHeader].[CustomerID]

Report this snippet  

You need to login to post a comment.