Wednesday, December 28, 2016

Get nth highest and lowest salary of an employee

Examples:
employee name and salary as shown in below fig.

Query to get nth(3rd) Highest Salary

  1. Select TOP 1 Salary as '3rd Highest Salary'
  2. from (SELECT DISTINCT TOP 3 Salary from Employee ORDER BY Salary DESC)
  3. a ORDER BY Salary ASC

Query to get nth(3rd) Lowest Salary

  1. Select TOP 1 Salary as '3rd Lowest Salary'
  2. from (SELECT DISTINCT TOP 3 Salary from Employee ORDER BY Salary ASC)
  3. a ORDER BY Salary DESC

Happy  Coding!!!!!!

No comments:

Search This Blog

DAX - Grouping on multiple columns and the count

Please go thorugh the below URL for entire soultion. http://community.powerbi.com/t5/Desktop/DAX-Grouping-on-multiple-columns-and-the-cou...