find out the third highest salary?
Answers were Sorted based on User's Feedback
Answer / swaminathan
select *
from (select distinct sal from emp order by sal desc)
where rownum <= 3
| Is This Answer Correct ? | 9 Yes | 13 No |
Answer / amitabh sharma
Here are 2 queries for finding 3rd highest salary:
select * from emp e
where 3 = (select count(sal) from emp
where e.sal < sal);
SELECT * FROM
(
SELECT Ename, SAL, dense_Rank() OVER (ORDER BY SAL DESC )
RANKNEW FROM EMP)
WHERE RANKNEW = 3
Regards,
Amitabh Sharma
| Is This Answer Correct ? | 1 Yes | 5 No |
Answer / ruchira
select sal from emp
where sal =
(select sal from
(select distinct sal from emp OrderBy sal desc)
[table alias] where rownum < 4 )
| Is This Answer Correct ? | 1 Yes | 5 No |
Answer / sapna rawal
SELECT TOP 1 salary
FROM (
SELECT DISTINCT TOP n salary
FROM employee
ORDER BY salary DESC)
ORDER BY salary ;
n=3.In this case.
| Is This Answer Correct ? | 1 Yes | 5 No |
Answer / anirban mitra
SELECT MAX(SAL) FROM EMP WHERE SAL NOT IN (SELECT MAX(SAL)
FROM EMP UNION SELECT MAX(SAL) FROM EMP WHERE SAL NOT IN
(SELECT MAX(SAL) FROM EMP))
| Is This Answer Correct ? | 2 Yes | 7 No |
Answer / nagaraj a h
SELECT DISTINCT (a.sal) FROM EMP A WHERE &N = (SELECT COUNT
(DISTINCT (b.sal)) FROM EMP B WHERE a.sal<=b.sal);
| Is This Answer Correct ? | 0 Yes | 5 No |
Answer / dayaram & sarfaraz (dost)
select a.empno,a.ename,a.sal from emp a
where &n = (select count(distinct(b.sal)) from emp b where
b.sal>= a.sal
| Is This Answer Correct ? | 0 Yes | 5 No |
Answer / asadullahrao
select max(sal) from emp where sal<(select max(sal) from
emp where sal<(select max(sal) from emp))
| Is This Answer Correct ? | 1 Yes | 6 No |
What is a Data File ?
What are the advantages of Views ?
What is a relational database management system?
what is primary key and foreign key when and where have to use
what is the difference between rollback & commit? can a foreign key has null value?
what are the things that you consider while creating indexes on partitioning tables?
For a field in a repeating frame, can the source come from the column which does not exist in the data group which forms the base for the frame ?
Can group functions be mixed with non-group selection fields?
 What are the oracle DML commands possible through an update strategy?
Briefly explain what is literal? Give an example where it can be used?
How to fetch the row which has the max value for a column?
1.What is inline function in oracle and its purpose? 2.What is the equivalent operator for "different from pattern" in oracle? 3. If you define a variable in oracle, how it will be available? [a. Until database shut down b. Until table deleted c. until session get expired]