xxxxxxxxxx
CREATE TABLE #Country(
CountryName Varchar(50)
)
INSERT INTO #Country VALUES('Nepal'),('India'),('Bangladesh'),('China'),('Nepal'),('Nepal')
SELECT CountryName, ROW_NUMBER() OVER (ORDER BY CountryName DESC) RowNum, RANK() OVER (ORDER BY CountryName desc) AS Ranks, DENSE_RANK() OVER (ORDER BY CountryName DESC) AS DenseRanks FROM #Country
xxxxxxxxxx
RANK gives you the ranking within your ordered partition.
Ties are assigned the same rank, with the next ranking(s) skipped.
So, if you have 3 items at rank 2,
the next rank listed would be ranked 5.
DENSE_RANK again gives you the ranking within your ordered partition,
but the ranks are consecutive.
No ranks are skipped if there are ranks with multiple items.
xxxxxxxxxx
RANK gives you the ranking within your ordered partition.
Ties are assigned the same rank, with the next ranking(s) skipped.
So, if you have 3 items at rank 2, the next rank listed would be ranked 5.
DENSE_RANK again gives you the ranking within your ordered partition,
but the ranks are consecutive.
No ranks are skipped if there are ranks with multiple items.