Write a query to find five highest salaries from EMP table.
(there is a column SALARY)
Answers were Sorted based on User's Feedback
Answer / k.prashanth
Select
ename,sal,deptno
from emp
where sal in
(select max
(sal) from emp
where
level<=5
connect by
prior sal<sal
group by level)
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / manoranjan sethy
Method 01:
---------
Select Ename, MAX (Sal) From Emp
Group by ROWNUM, Ename
Having Rownum <=5;
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / vivek dubey
this Query is wrong : " SELECT ENAME,SALARY FROM (SELECT ENAME,SAL FROM EMP ORDER BY SALARY DESC ) WHERE ROWNUM<6; " because We can not use Order by clause in SubQuery.
This Answer gives you the right data :
"
SELECT TOP 5
empsal.ENAME,
empsal.SAL
FROM
(
SELECT ENAME,SAL
FROM EMP
) AS empsal
ORDER BY empsal.SAL DESC
"
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / ajay dond
select salary from (select distinct salary from employees
order by salary desc)
where rownum<6
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / ram
select ename,salary from(select ename,salary from emp order by salary desc) where rownumber<6
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / kishore
select salery from (select salery from
emp order by salery desc) where rownum <=5 ;
Is This Answer Correct ? | 2 Yes | 3 No |
Answer / manjunath u
select salary from(select salary from emp order by salary
desc)where rownum<=5;
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / kavitha nedigunta
select a.*
from(select empno,ename,sal
from emp
order by sal desc nulls last)a
where rownum <6
order by sal desc
Is This Answer Correct ? | 3 Yes | 5 No |
Answer / mohammad murtuza ali
select * from emp as(empname,empsal,empdesc) where rownum<6
Is This Answer Correct ? | 1 Yes | 4 No |
What is the diffrence between IN and EXISTS.which one is faster.
what is timestamp in mysql? : Sql dba
what are %TYPE and %ROWTYPE? what is the difference?
7 Answers ICICI, Saama Tech, Sail,
what is the difference between binary_integer and pls_integer
what are the disadvantages of mysql? : Sql dba
How many null values can be inserted in a coulmn whihc is unique constraint
How do I tune a sql query?
What is java sql drivermanager?
What is example of database?
What is oracle pl sql developer?
How can you load microsoft excel data into oracle? : aql loader
How to fetch values from testtable1 that are not in testtable2 without using not keyword?