HI, ItS URGENt PLZ ANSWER
to find top 10 salaries of employees with their names
Collapse
X
-
to find top 10 salaries of employees with their names
Tags: None -
Hi,
This is one of the most frequently asked and also most frequently answered question. Oracle has a built in function call rank() which has been introduced specifically to rank the records based an a criterion.So selecting the top 10 employees based on their salaries will look like this:
SELECT NAME,RANK ()OVER(ORDER BY SALARY DESC) RNK
FROM EMP
WHERE RNK < 11
However if there are two employees with the same salaries, the above query will assign the same rank to them (say 2) and skip the next rank(3) and assign rank 4 to the next employee. This means no continuity in ranking. If you want continuity then use DENSE_RANK() in place of RANK(). -
hi,
You can try this out....
select ename,sal from (select ename,sal from emp order by sal)where rownum<=10;
This will give u ur desired result.Comment
Comment