how to assign ranks for employee based on their salary? [Resolved]

Posted by Rajendra.prasad under Sql Server on 3/22/2010 | Views : 2359 | Status : [Member] | Replies : 2
Hi All,
in general EMP table, who to write an query for assigning ranks for all employee based on their salary.

Regards,
Rajendra




Responses

Posted by: Lakhangarg on: 3/22/2010 [Member] [Moderator] Silver

Up
0
Down

Resolved
Hi rajendra-

Use the following query for this:

SELECT ROW_NUMBER() OVER (ORDER BY EMPSalery DESC) AS RANK, EMPID, EmpName, EmpSalery, * FROM EMPLOYEE


Thanks
Lakhan Pal Garg

Rajendra.prasad, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pandians on: 3/22/2010 [Member] [MVP] Silver

Up
0
Down
Hi Rajendra.prasad

You can use one of the Ranking function.

DENSE_RANK() with Descending order of Salary.

Cheers


Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Rajendra.prasad, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response