from the table display the 2nd highest salary?
and also the least 2nd salay?

Answers were Sorted based on User's Feedback



from the table display the 2nd highest salary? and also the least 2nd salay? ..

Answer / soorai ganesh

SELECT 'Second Highest Salary Is ', MAX(Salary) FROM Employee WHere Salary < ( Select MAX(Salary) FROM Employee )

SELECT 'Second Least Salary Is ',MIN(Salary) FROM Employee WHere Salary > ( Select MIN(Salary) FROM Employee )

Is This Answer Correct ?    7 Yes 2 No

from the table display the 2nd highest salary? and also the least 2nd salay? ..

Answer / mehul

for 2nd highest salary

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


for 2nd least salary

select min(salary) from employee where salary>(select min
(salary) from employee )

i hope that will help you

Is This Answer Correct ?    3 Yes 0 No

from the table display the 2nd highest salary? and also the least 2nd salay? ..

Answer / bobby

select p.emp_id,p.name,p.salary from
(select emp_id,name,salary,dense_rank()over( order by
salary desc)maxrank,
dense_rank()over( order by salary asc)minrank from test)p
where maxrank=2 or minrank=2

Is This Answer Correct ?    2 Yes 0 No

from the table display the 2nd highest salary? and also the least 2nd salay? ..

Answer / smitha

2nd Highest Salary

Select top 1 salary from (select distinct top 2 salary
from employee order by salary desc)a
order by salary

2nd Least Salary

Select top 1 salary from (select distinct top 2 salary
from employee order by salary asc)a
order by salary desc

Is This Answer Correct ?    3 Yes 2 No

from the table display the 2nd highest salary? and also the least 2nd salay? ..

Answer / sridhar sahoo

select distinct top 1 salary from payroll..emp where salary
in(select distinct top 3 salary from payroll..emp order by
salary desc)

Is This Answer Correct ?    1 Yes 0 No

from the table display the 2nd highest salary? and also the least 2nd salay? ..

Answer / prasanthi

Query for Getting 2nd least salary (replace 2 with any
number so that you will get any least salary:

select max(Salary) from Employee
where Salary in
(select distinct top 2 Salary from dbo.Employee order by
Salary asc)

Query for Getting 2nd Height salary (replace 2 with any
number so that you will get any least salary:

select min(Salary) from Employee
where Salary in
(select distinct top 2 Salary from dbo.Employee order by
Employee desc)

Is This Answer Correct ?    1 Yes 0 No

from the table display the 2nd highest salary? and also the least 2nd salay? ..

Answer / sridhar sahoo

select distinct top 1 salary from payroll..emp where salary
in(select distinct top N salary from payroll..emp order by
salary desc)

if u want top 2 put 2 at the pacece of N
if u want top 5 put 5 at the pacece of N
if u want ..............................

Is This Answer Correct ?    0 Yes 0 No

from the table display the 2nd highest salary? and also the least 2nd salay? ..

Answer / narayana

select top 1 sal from (
select top 2 sal from Emp order by sal desc) as a order by sal asc


select top 1 sal from(
select top 2 sal from Emp order by sal ) ss order by sal desc

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

What type of Index will get created after executing the above statement?

0 Answers  


What objects does the fn_my_permissions function reports on? : sql server security

0 Answers  


Does a server store data?

0 Answers  


Can we call future method from trigger?

0 Answers  


How to declare and use cursor variables?

0 Answers  






create index a on employee(dno) In this,which index was created?

2 Answers  


If you are working on a SQL database and if suddenly a developer changes the code and your queries results start giving errors,how will you check using a T-SQL query (on system tables) that what has changed in the database.

2 Answers   Microsoft,


What are the disadvantages of using the stored procedures?

0 Answers  


Explain boyce and codd normal form(bcnf)?

0 Answers  


Write the Syntax for Cursors.

2 Answers   CarrizalSoft Technologies, HP,


What is Transparent Data Encryption?

0 Answers  


How to call stored procedure using http soap?

0 Answers  


Categories