how to find the second highest salary from emp table?

Answers were Sorted based on User's Feedback



how to find the second highest salary from emp table?..

Answer / krishna kishore

select top 1 salary from emp where salary in
(select top 2 salary from emp order by salary desc)
order by salary

Is This Answer Correct ?    1 Yes 0 No

how to find the second highest salary from emp table?..

Answer / kiran

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

/

Is This Answer Correct ?    1 Yes 0 No

how to find the second highest salary from emp table?..

Answer / ramcharan tej

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

Is This Answer Correct ?    1 Yes 0 No

how to find the second highest salary from emp table?..

Answer / anurag kumar rai

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

Is This Answer Correct ?    1 Yes 0 No

how to find the second highest salary from emp table?..

Answer / sachin verma

select sal from emp
where rownum=2
order sal by Desc

Is This Answer Correct ?    1 Yes 0 No

how to find the second highest salary from emp table?..

Answer / anil maurya

select top 1 rate from HumanResources.EmployeePayHistory
where rate<(select MAX(rate) as R from HumanResources.EmployeePayHistory)
order by rAte Desc

Is This Answer Correct ?    1 Yes 0 No

how to find the second highest salary from emp table?..

Answer / surendra sharma

select min(sal) from table_name where sal in

(SELECT top 2 sal FROM table_name order by sal desc)

Is This Answer Correct ?    1 Yes 0 No

how to find the second highest salary from emp table?..

Answer / yash goyal

Select Distinct salary
from employees e
where &no-1=(select count(distinct salary )
from employees
where E.salary < salary);

Is This Answer Correct ?    1 Yes 0 No

how to find the second highest salary from emp table?..

Answer / bharat g

select * from (select ename,sal,dense_rank() over (order by sal desc) ranking from emp) where ranking=2;

Is This Answer Correct ?    1 Yes 0 No

how to find the second highest salary from emp table?..

Answer / vinay

select max(sal) from emp where rownum = 2;

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

how a reference cursor works?what all adnvantages are gained with it..specify the situation?

4 Answers   TCS,


Explain the insert into statements in sql?

0 Answers  


what is overloading procedure or overloading function ?

3 Answers   Genpact,


What is a variable in sql?

0 Answers  


What are the two types of cursors in pl sql?

0 Answers  






which operator is used in query for pattern matching? : Sql dba

0 Answers  


Is it possible to pass parameters to triggers?

0 Answers  


Are subqueries faster than joins?

0 Answers  


What is primary and foreign key?

0 Answers  


Use The Implicit cursor to Query The Department table information Where Deptno is 30.check,if no record was found then print "Record Was Not Found".Else Print Deptname And Ename.Dept table Have Dname Varchar2(20),Deptno Number,EnameVarchar2(20).Please Answer In 2 mins,with in Maximum 15 lines.

5 Answers   Wipro,


If i insert record in table A and these record should update in table B by using Trigger.How to achieve this.

4 Answers   Saama Tech, TCS,


Do we need to rebuild index after truncate?

0 Answers  


Categories