WITH #temp AS (SELECT ROW_NUMBER() OVER( ORDER BY SUM(nReceiveVolume) desc) AS indexof,SUM(nReceiveVolume) AS sumVolume,vcCustID FROM Ord_PurchaseOrder GROUP BY vcCustID) SELECT * FROM #temp WHERE vcCustID='201010192292000844'