This article is to explain the functionality of Rank() function in SQL Server 2005. In our schooling days if the over all score of two guys are the same in exams then they would be ranked as 1 each and the next guy would get 3rd rank and not 2nd rank. To achieve same kind of result in SQL Server 2005 we can make use of this Rank() function. Extract from MSDN: If two or more rows tie for a rank, each of the tied rows receives the same rank. For example, if the two top sales people have the same SalesYTD value, then they are both ranked one. The sales person with the next highest SalesYTD is ranked number three, since there are two rows that are ranked higher. Therefore, the RANK function does not always return consecutive integers. Table Structure for the sample table: Create table DemoRankingFunction ( Sno int identity, FirstName varchar(25), Marks int ) Sample records for the demo purpose: Insert into DemoRankingFunction Values ('Vadivel',99) Insert into DemoRankingFunction Va
I write about things which I am passionate about.