
SELECT orderid, customerid, 
  ROW_NUMBER() OVER(ORDER BY customerid) AS num,
  RANK()       OVER(ORDER BY customerid) AS [rank],
  DENSE_RANK() OVER(ORDER BY customerid) AS [denserank],
  NTILE(5)     OVER(ORDER BY customerid) AS ntile5
FROM  orders
WHERE orderid < 10400
AND   customerid <= 'BN'

select * from orders
 order by customerid 
