Write a query to find second highest salary of an employee.

Answers were Sorted based on User's Feedback



Write a query to find second highest salary of an employee. ..

Answer / rajkumar mandala

select sal from
(select sal,(row_number() over (order by sal)) N from emp ) y where N= {value}

Replace {value} value with required highest value.
ie, 2 for 2nd highest

Is This Answer Correct ?    7 Yes 3 No

Write a query to find second highest salary of an employee. ..

Answer / aj

select * from emp A where 1=(select count(*) from emp B
where A.SALARY < B.SALARY)

Is This Answer Correct ?    12 Yes 9 No

Write a query to find second highest salary of an employee. ..

Answer / girase hitendrasing a.

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

Is This Answer Correct ?    5 Yes 2 No

Write a query to find second highest salary of an employee. ..

Answer / bhaskar reddy thamma

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 ?    2 Yes 0 No

Write a query to find second highest salary of an employee. ..

Answer / n.tejaswi

Select Empname
from emp LIMIT 2
orderby empsal;

Is This Answer Correct ?    2 Yes 1 No

Write a query to find second highest salary of an employee. ..

Answer / khurram

The Simplest, easy, Understandable solution is

select max(sal) from emp where
sal not in
(select distinct Top 1 sal from emp order by sal desc)


Go Check Out for yourself
[replace "top 1" by "top 2" to get 3rd highest sal]
[replace "top 1" by "top 3" to get 4th highest sal] so on..

Is This Answer Correct ?    2 Yes 1 No

Write a query to find second highest salary of an employee. ..

Answer / jyo

select salary from employee where salary>1st

Is This Answer Correct ?    3 Yes 2 No

Write a query to find second highest salary of an employee. ..

Answer / ujwlala

select max(salary) from employee where salary<>(select
max(salary) from emp)

Is This Answer Correct ?    2 Yes 1 No

Write a query to find second highest salary of an employee. ..

Answer / satish

select e1.* from emp e1 where 1=(select count(distinct
e2.sal) from emp e2 where e2.sal>e1.sal)

Is This Answer Correct ?    2 Yes 1 No

Write a query to find second highest salary of an employee. ..

Answer / ashutosh singh

select distinct(a.Sal) from emp a where &n=(select
count(distinct(b.Sal)) from emp b where b.Sal<a.Sal)

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More Automation Testing AllOther Interview Questions

what is the importance of action in QTP & When it need to use it ? I m getting it please expian it me with proper example.

0 Answers  


How you will evaluate the tool for test automation?

1 Answers  


To retrive testdata which tool vl use?

1 Answers   IBM,


What are software testing metrics

4 Answers   MBT, Persistent,


What is Automation Testing Framework

5 Answers   Covansys,






If I have given names to different DataTable columns and those column names are stored in a variable, then passing that variable to the datatable how can i Enter different values in those columns listed in that variable?? Please explain me with an example.I am not getting it.

0 Answers  


Hi Friends this is Srinivas. I feel very happy to share my doubts with u.what is main difference between client server application and webserver application.Nobody discribed.please send me good answer about that. my mail id:dsrao106@gmail.com.

4 Answers   IBM,


How to create stubs? what is the use of Stubs and drivers? who is the responsible person of this?

4 Answers  


plz explain QTP real time work( Means where you store scripts and how u access scripts next day? where those activities we are maintaining, If By usig VSS how the process in going on , plz explain briefly?

0 Answers   CTS,


WHAT WE CAN NOT DO WITH QTP? GIVE 5 POINTS.(EXCEPT PERFOMANCE)

1 Answers   Accenture, Leo Technologies,


How will you choose a tool for test automation?

3 Answers  


What is extreme programming and what has it got to do with testing?

0 Answers  


Categories