How to retrieve 5th highest sal from emp table?
Answers were Sorted based on User's Feedback
Answer / amit bhagat
select min(a.sal) from (select distinct(d.sal) from emp
order by d.sal desc) a where rownum<=5
Is This Answer Correct ? | 5 Yes | 0 No |
Answer / venkata
hi, earlier query return sal in asending order and when
duplicate salries are there the earlier highest salary
position returns no rows. I hope this is better query.
select * from (select * from emp order by sal desc)
group by
rownum,empno,ename,job,mgr,hiredate,sal,comm,deptno having
rownum=&n
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / aryasen vaikom
SELECT DISTINCT (a.sal)
FROM EMP A
WHERE 5= ( SELECT COUNT (DISTINCT (b.sal))
FROM EMP B
WHERE a.sal<=b.sal )
Is This Answer Correct ? | 5 Yes | 2 No |
Answer / venubabu
Select level,Max(sal) from emp
Where level=&level connect by prior sal>sal
group by level;
sql>Enter value for level:5
Is This Answer Correct ? | 3 Yes | 1 No |
Answer / arvind patil
select rownum,name,salary
from (select name,salary
from employee
order by salary desc )
where rownum=5;
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / lingareddy
select top 1 salary from (select distinct top 5 salary from emp order by salary desc ) a order by salary asc
if u have any doubts in SQL kindly reach with me,
Thanks & Regards,
Lingareddy.S
sabbasani.reddy1@gmail.com
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / jithendranath.g
select z2.sal from emp z1, emp z2
where z2.sal <=z1.sal
group by z2.sal
having count(z2.sal)=&n
Is This Answer Correct ? | 0 Yes | 1 No |
how to store only time in a data base table
hi friends i completed b.com 2004.i have 3y accounting exp. in manufacturing company.now i have completed oracle finance.pls suggest me how will get job in oracle.can i get job in oracle.
Why do I get java.lang.abstractmethoderror when trying to load a blob in the db?
master table and child table performances and comparisons in Oracle ?
Is there a function to split a string in plsql?
How to get a list of all tables in the database?
normally database take to refresh time 2 hours. but client asked iwant to refresh with in 5 min that same database. do you have any option in BO and Oracle? explain me briefly...kavi
Why cursor variables are easier to use than cursors?
Query to retrieve record for a many to many relationship ?
In not less than 100 words what's the main difference between Rolap and Molap in ORACLE ?
In the oracle version 9.3.0.5.0, what does each number shows?
Oracle
0 Answers ABC, Genpact, HUI, Oracle,