Write a query to get 2nd maximum salary in an employee table ?

Answers were Sorted based on User's Feedback



Write a query to get 2nd maximum salary in an employee table ?..

Answer / jebitha

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

Is This Answer Correct ?    7 Yes 9 No

Write a query to get 2nd maximum salary in an employee table ?..

Answer / babbu

it's easy with self join:
select max(sal) from emp e1,emp e2 where e1.sal < e2.sal

Is This Answer Correct ?    0 Yes 2 No

Write a query to get 2nd maximum salary in an employee table ?..

Answer / lakshminarayana reddy

select rownum,empno,ename,job,sal from emp(select
rownum,empno,ename,job,sal from emp order by sal desc) grop
by rownum,empno,ename,job,sal having rownum=2;

Is This Answer Correct ?    7 Yes 10 No

Write a query to get 2nd maximum salary in an employee table ?..

Answer / varun

select max(sal) from emp ((select sal from emp)-(select max
(sal) from emp))

Is This Answer Correct ?    5 Yes 8 No

Write a query to get 2nd maximum salary in an employee table ?..

Answer / naresh kumar kalangi

select top 1 * from (select top 2 * from emp order by sal
desc)s order by sal

Is This Answer Correct ?    5 Yes 8 No

Write a query to get 2nd maximum salary in an employee table ?..

Answer / surajit pathak

select * from emp e1
where 2>(select count(1) from emp e2
where e2.sal>e1.sal)
order by sal desc

Is This Answer Correct ?    1 Yes 4 No

Write a query to get 2nd maximum salary in an employee table ?..

Answer / satya_k21

Hi,


Select * from emp e where 2>= (select count(sal) from
emp e where sal>=e.sal) order by desc.

Let me know if it is wrong..


Regards,
Satya.K

Is This Answer Correct ?    11 Yes 16 No

Write a query to get 2nd maximum salary in an employee table ?..

Answer / rajesh.m

Crete Table Curtest(Emp char(40),salary money)
------------------------------------------------
Select Min(Salary) from Curtest where Salary
in (select Top 2 Salary from Curtest)

--------------------------------------------------

Is This Answer Correct ?    21 Yes 33 No

Write a query to get 2nd maximum salary in an employee table ?..

Answer / varun

select sal from emp where rownum=2 order by sal desc;

Is This Answer Correct ?    6 Yes 19 No

Post New Answer

More SQL PLSQL Interview Questions

What are the ways on commenting in a pl/sql code?

0 Answers  


From an Employee table, how will you display the record which has a maximum salary?

29 Answers   Cap Gemini, Exilant, Synechron,


What is insert command in sql?

0 Answers  


Mention what are different methods to trace the pl/sql code?

0 Answers  


What is difference between joins and union?

0 Answers  






How do I restart sql?

0 Answers  


How to know the last executed procedure?

0 Answers  


is it mandatory to select all the column in a view then what columns should be selected

2 Answers  


Why we use pl sql?

0 Answers  


What is the file extension for sql database?

0 Answers  


What is the main difference between a UNION statement and a UNION ALL statement? 1. A UNION statement eliminates duplicate rows; a UNION ALL statement includes duplicate rows. 2. A UNION statement can be used to combine any number of queries; a UNION ALL statement can be used to combine a maximum of two queries. 3. A UNION statement can only combine queries that have parallel fields in the SELECT list; a UNION ALL statement can combine queries with differing SELECT list structures. 4. A UNION statement cannot be used with aggregate functions; a UNION ALL statement can be used with aggregate functions. 5. There is no difference between the two statements; they are interchangeable.

2 Answers   Saman Bank, Sonata,


What is the purpose of a secondary key?

0 Answers  


Categories