Member
164
Points
|
Replied on
28 Aug 2013 10:29 PM IST
What is the difference between RANK & DENSE RANK Functions? Give Syntax.
RANK Functions use ORDER BY clause.
SELECT NAMEOFTHEBANK, Branches, RANK() OVER(ORDER BY Branches DESC) AS RANKID, ROW_NUMBER() OVER(ORDER BY Branches DESC) AS ROWNO, DENSE_RANK() OVER(ORDER BY Branches DESC) AS DENSERANK, NTILE(3) OVER(ORDER BY Branches DESC) AS NT FROM tbl_Banks GROUP BY NAMEOFTHEBANK RANK() give same ranking for same records and it will skips the duplicate ranks.
example (rank 3 will never assign to any record)
Marks Rank 98 1 97 2 97 2 96 4
DENSE_RANK() give same ranking for same records and it will continues to the next rank.
example
Marks Rank 98 1 97 2 97 2 96 3
|