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...


can anybody tell us, how to select 2nd max salary from
table.
my id is ashish.akk@gmail.com

Answers were Sorted based on User's Feedback



can anybody tell us, how to select 2nd max salary from table. my id is ashish.akk@gmail.com..

Answer / arun ashok

Select max(salary) from employee where salary not in (select
max(salary) from employee)

Is This Answer Correct ?    1 Yes 1 No

can anybody tell us, how to select 2nd max salary from table. my id is ashish.akk@gmail.com..

Answer / sandeep rana

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

Is This Answer Correct ?    0 Yes 0 No

can anybody tell us, how to select 2nd max salary from table. my id is ashish.akk@gmail.com..

Answer / pravin

select max(sal) from emp
where sal=(select max(sal)
from emp
where sal<(select max(sal)
from emp))

Is This Answer Correct ?    0 Yes 0 No

can anybody tell us, how to select 2nd max salary from table. my id is ashish.akk@gmail.com..

Answer / prasad237

with x as(select row_number over(order by sal desc) as rid,* from emp)
select * from x where rid=n
we can retrieve nth max sal

Is This Answer Correct ?    0 Yes 0 No

can anybody tell us, how to select 2nd max salary from table. my id is ashish.akk@gmail.com..

Answer / syaam

select a.sal from emp a
where 2=(select count(distinct b.sal) from emp b
where a.sal<= b.sal)


for getting nth max sal ..replace 2 by n


all the best

Is This Answer Correct ?    0 Yes 1 No

can anybody tell us, how to select 2nd max salary from table. my id is ashish.akk@gmail.com..

Answer / swapnl

select max(sal) from emp_det where sal not in (
select max(sal) from emp_det);

Is This Answer Correct ?    0 Yes 1 No

can anybody tell us, how to select 2nd max salary from table. my id is ashish.akk@gmail.com..

Answer / raj

Sabin's answer is perfect and simple

Is This Answer Correct ?    0 Yes 1 No

can anybody tell us, how to select 2nd max salary from table. my id is ashish.akk@gmail.com..

Answer / kumar

1 My Second Answer.

Select Top 1 * From Tablename where salary in
(select top 2 salary from tablename order by salary desc)
order by salary asc.

Is This Answer Correct ?    0 Yes 4 No

Post New Answer

More SQL Server Interview Questions

how can u select the Distinct values in the table, table having 20 columns , i want all columns

2 Answers  


What are the differences in Clustering in SQL Server 2005 and 2008 or 2008 R2?

0 Answers  


Can Somebody tell me the difference between Clustered & Non- Clustered Index??

5 Answers   Progressive,


What are the kinds of subquery?

0 Answers  


Why should one not prefix user stored procedures with ‘sp_’?

0 Answers  


Can we take the full database backup in log shipping?

0 Answers  


How to create a local temporary stored procedure?

0 Answers  


What are different types of Keys? Please explain all the keys with a suitable example.

4 Answers  


What stored procedure would you use to view lock information?

0 Answers  


How to move database physical files in ms sql server?

0 Answers  


What are the different types of replication? How are they used?

3 Answers  


Explain syntax for dropping triggers?

0 Answers  


Categories