top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to get records with rank between 5 and 10

0 votes
457 views

I have an employee table with 20 records. The columns are employee name and salary. How can I get the details of employees with ranks between 5 and 10 on the basis of decreasing order of their salaries?

I am thinking of passing the table through a sorter to arrange the data in decreasing order of salaries, and then Sequence Generator Transformation giving unique id to the rows and finally a filter to select where the id is between 5 and 10. I realise this isn't an elegant solution? Is there a better way to do this? Thanks for your time

posted Sep 3, 2014 by Amit Sharma

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

this query helps:

SELECT *
FROM (SELECT ename, sal, DENSE_RANK () OVER (ORDER BY sal DESC) ranking
FROM emp)
WHERE ranking BETWEEN 5 AND 10;

answer Sep 12, 2014 by Archana
0 votes

You can use rank transformation to get the top 10 salaried persons. Then you can filter out the first 5 using the rankindex column

answer Sep 8, 2014 by Shweta Singh
...