please tell me the query to get details of the employee
having the second largest salary

Answers were Sorted based on User's Feedback



please tell me the query to get details of the employee having the second largest salary..

Answer / shivangi

Select max(Salary) from employeetable where salary < (select
max(salary) from Employeetable)

Is This Answer Correct ?    11 Yes 1 No

please tell me the query to get details of the employee having the second largest salary..

Answer / sushil

select min(a.standardcost) from
(
select distinct top 2 StandardCost
from Production.ProductCostHistory
order by standardcost desc
)a

Is This Answer Correct ?    5 Yes 1 No

please tell me the query to get details of the employee having the second largest salary..

Answer / krishna mohan thamisetty

SELECT * FROM Emp e1
WHERE 2 = (SELECT COUNT(*) FROM Emp e2 WHERE e1.Salary <=
e2.Salary)

Is This Answer Correct ?    6 Yes 3 No

please tell me the query to get details of the employee having the second largest salary..

Answer / eswar

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

Is This Answer Correct ?    4 Yes 1 No

please tell me the query to get details of the employee having the second largest salary..

Answer / devendra dwivedi

Select * from EmpTbl Where Salary = (Select Max(Salary) from
EmpTbl Where Salary < (Select Max(Salary) from EmpTbl)

Is This Answer Correct ?    3 Yes 1 No

please tell me the query to get details of the employee having the second largest salary..

Answer / rathi

If we had a table named Employee which had a column named
Salary and we had to find the second highest Salary in the
Employee table, the query for the same would be:

SELECT TOP 1 Salary FROM (SELECT TOP 2 Salary FROM Employee
ORDER BY Salary DESC) AS E ORDER BY Salary ASC

The subquery or the inner query would return the top 2 rows
in descending Salary order which would be:
5000
4000
The outer query would then select the top 1 row from the
subquery results in ascending Salary order which would be:
4000

Is This Answer Correct ?    2 Yes 0 No

please tell me the query to get details of the employee having the second largest salary..

Answer / ss

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

Is This Answer Correct ?    1 Yes 0 No

please tell me the query to get details of the employee having the second largest salary..

Answer / roshan

select employeeid, employeeName ,Salary from table1 where
Salary =(select min(a.Salary) from table1 inner join
(select top 2 Salary from table1
order by Salary desc) a on table1.Salary = a.Salary)

if we change the top value we will get the n'th largest
salary

Is This Answer Correct ?    0 Yes 0 No

please tell me the query to get details of the employee having the second largest salary..

Answer / ram

SELECT TOP 1 ESAL
FROM
(
SELECT DISTINCT TOP 2 ESAL
FROM EMPLOYEE
ORDER BY ESAL DESC
)ABC
ORDER BY ESAL ASC

Is This Answer Correct ?    0 Yes 0 No

please tell me the query to get details of the employee having the second largest salary..

Answer / ajay sara

Select Min(Salary) From (Select Top N * From Table_Name
Order by Salary Desc)

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

Your company has 50 branches all over the country all the branches, including the head office have sql server as the database every night all 50 branches upload certain information to the head office which replication topology is best suited for the above scenario?

0 Answers  


Explain the xml support sql server extends?

0 Answers  


How will oyu test the stored procedure taking two parameters namely first name and last name returning full name?

3 Answers  


What is the query optimization statistics?

1 Answers  


What is SCOPE_IDENTITY() in sql

4 Answers   Cap Gemini,






How do I run sql server 2014?

0 Answers  


how to copy only distinct data into another table which is not already exist in database?

2 Answers   Spectra,


What is blocking?

0 Answers  


what is the maximum size of a row in sql server 2000 and 2005

2 Answers  


What is database isolation in sql server? : sql server database administration

0 Answers  


Different types of keys in SQL?

0 Answers   Infosys,


Explain the storage models of OLAP?

1 Answers  


Categories