how will I find the first 5 highest salaried employees in
each dept in oracle.
Answers were Sorted based on User's Feedback
Answer / sunil panghal
select rownum as row_id,salary from (select salary from
employees order by salary) where rownum <6;
Is This Answer Correct ? | 1 Yes | 2 No |
Answer / rammohan
select rownum as row_id,sal from (select sal from
emp order by sal desc) where rownum <6;
Is This Answer Correct ? | 1 Yes | 2 No |
Answer / uttam
select sal from (SELECT distinct sal FROM emp order by sal
desc)
where rownum <6
Is This Answer Correct ? | 13 Yes | 15 No |
Answer / manjusure@yahoo.co.in
select * from emp e where 5> (select count(max(sal)) from emp
where e.deptno=deptno and sal>e.sal group by sal);
Is This Answer Correct ? | 4 Yes | 6 No |
Answer / mihir nasikkar
select *
from employee X
where salary in (select top 5 salary
from employee
where dept = X.dept
order by salary desc)
order by dept, salary desc
Is This Answer Correct ? | 2 Yes | 4 No |
Answer / mangesh
SELECT * FROM (SELECT * FROM EMP ORDER BY SALARY desc) WHERE ROWNUM < 6;
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / md valiyullah
select max(sal)-5 from emp where dept = 'sale'
union all
select max(sal)-5 from emp where dept = 'purchase'
Is This Answer Correct ? | 0 Yes | 4 No |
Answer / dhanalakshmi
select salary
from employee
where rownum<6
group by deptno,salary
order by salary desc
Is This Answer Correct ? | 0 Yes | 9 No |
How to define a sub function?
how to select alphabets in a one column , for this the table name is PA_TASKS and column name is TASK_NUMBER, In TASK_NUMBER the data like this 1.1.3NN,1.1.4NN,1.5.1NN,1.3.2NE,1.5NN,1NN,1.2NE,1CE , For this i need to disply output as only NN,but not other alphabets, if NN is thre means i should display , otherwise leave that blank or empty Its some urgent requirement ,thanks in advance
Can the query output be sorted by multiple columns in oracle?
How to update values on multiple rows in oracle?
How many different types of indexes we have in oracle?
24 Answers IBM, TCS,
What is Reduced List of Values?
What is the difference between 10g OEM and 11g OEM?
When can Hash Cluster used ?
What are the different types of trigger and explain its various uses and functions?
What are transaction isolation levels supported by oracle?
What are the different pseudo commands? Explain in general?
How to omit columns with default values in insert statement in oracle?