find out the second highest salary?

Answers were Sorted based on User's Feedback



find out the second highest salary?..

Answer / mallikarjun

select max(sal) from emp
where sal < select max (sal)from emp






Mallikarjun

Is This Answer Correct ?    216 Yes 86 No

find out the second highest salary?..

Answer / ananth

this is for 2nd highest sal in sql server database

select * from emp where sal=(select max(sal) from emp where
sal<(select max(sal) from emp))

Is This Answer Correct ?    119 Yes 13 No

find out the second highest salary?..

Answer / v.karthikeyan

select * from emp
where &n-1=(select count(distinct(sal)) from emp b
where emp.sal<b.sal)

Is This Answer Correct ?    62 Yes 30 No

find out the second highest salary?..

Answer / hiten

select max(sal) from emp where sal not in(select max(sal)
from emp);

Is This Answer Correct ?    25 Yes 2 No

find out the second highest salary?..

Answer / prasant

SQL> select max(sal) from emp where sal<(select max(sal)
from emp);

MAX(SAL)
----------
3000

Is This Answer Correct ?    22 Yes 3 No

find out the second highest salary?..

Answer / abhijit ramakant parb

select min(a.sal) from(select distinct d.sal from emp d
order by sal desc) a where rownum<=2;

To retrieve all columns

select * from emp where sal=(select min(a.sal) from(select
distinct d.sal from emp d order by sal desc) a where
rownum<=2);

Is This Answer Correct ?    12 Yes 6 No

find out the second highest salary?..

Answer / karthikeyan

select max(sal) from emp
where sal <(select max (sal)from emp);

Is This Answer Correct ?    7 Yes 1 No

find out the second highest salary?..

Answer / premsagar12

select max(sal) from emp where sal<(select max(sal) from emp);

Is This Answer Correct ?    7 Yes 1 No

find out the second highest salary?..

Answer / peter

SQL> select max(sal) sal
2 from (select sal,
3 dense_rank() over
4 (order by sal desc) rnk
5 from emp )
6 where rnk = 2;

SAL
----------
3000

SQL>

Is This Answer Correct ?    14 Yes 9 No

find out the second highest salary?..

Answer / janmejaya

select top(1) * from employee where salary in (select
distinct top(2) salary from employee order by salary desc)
order by Salary




Above query is dynamic, if u want 3rd highest then just
change 2 to 3 , Please Try It

Is This Answer Correct ?    4 Yes 0 No

Post New Answer

More Oracle General Interview Questions

What are advantages fo Stored Procedures?

1 Answers  


Respected sir, Please send me technical questions related to oracle apps..

0 Answers  


10. Display the client number, order date and shipping date for all orders where the shipping date is between three and six months after the order date.

3 Answers   Wipro,


Please explan Why static query is more faster than dynamic query ?

2 Answers  


What is the function of Redo Log ?

1 Answers  






Can you assign multiple query result rows to a variable?

0 Answers  


What are the numeric comparison operations?

0 Answers  


What are the composite date types in oracle?

6 Answers   HCL,


What is the database name in oracle?

0 Answers  


How do I call oracle stored procedures that take no parameters?

0 Answers  


what is port in oracle? how is it related to database application.

0 Answers  


Who developed oracle & when?

0 Answers  


Categories
  • Oracle General Interview Questions Oracle General (1789)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (510)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)