Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

wat wil hapn if we give the both read and deny read permission to user?

0 Answers   IBM,


What is the difference between referencing and joining?

1 Answers  


What happens if time-only values are provided as date and time literals?

0 Answers  


How to count the number of duplicate items in a table?

3 Answers  


I have a huge amount of data which is displayed in a report. The data is viewed every day. Every day the data is displayed in 30 secs but suddenly today it is giving an timeout message today. Data has not been changed. The situation is same as yesterday. What might be the reason??? Please Answer.

4 Answers   Satyam,


What is RAID? What are the different types of RAID configurations?

0 Answers   Flextronics,


What value could be assigned to Varchar Type?

3 Answers  


Your table has a large character field there are queries that use this field in their search clause what should you do?

0 Answers  


What is trace flag in sql server?

0 Answers  


What are character string data types in ms sql server?

0 Answers  


How to include date and time values in sql statements?

0 Answers  


what are user defined datatypes? : Sql server database administration

0 Answers  


Categories