top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

How to get records with rank between 5 and 10

0 votes
65 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
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...