﻿ AdventureWorks: Return the top ten employees ranked by their salary

# AdventureWorks Database: Return the top ten employees ranked by their salary

## SQL Query - AdventureWorks: Exercise-117 with Solution

117 From the following table write a query in SQL to return the top ten employees ranked by their salary.

Sample table: HumanResources.EmployeePayHistory

Click to view Full table

Sample Solution:

``````SELECT BusinessEntityID, Rate,
DENSE_RANK() OVER (ORDER BY Rate DESC) AS RankBySalary
FROM HumanResources.EmployeePayHistory
FETCH FIRST 10 ROWS ONLY;
``````

Sample Output:

```businessentityid|rate   |rankbysalary|
----------------+-------+------------+
1|  125.5|           1|
25|84.1346|           2|
273|72.1154|           3|
2|63.4615|           4|
234|60.0962|           5|
263|50.4808|           6|
7|50.4808|           6|
234|48.5577|           7|
287| 48.101|           8|
274| 48.101|           8|
```

## Practice Online

Contribute your code and comments through Disqus.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.

﻿

`DATE_FORMAT(FROM_UNIXTIME(`user.registration`), '%e %b %Y') AS 'date_formatted'`