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 to convert a numeric expression from one data type to another?

0 Answers  


What are statistics, under what circumstances they go out of date, how do you update them?

2 Answers   HCL,


Can a stored procedure call another stored procedure. If yes what level and can it be controlled?

2 Answers  


WRITE A FUNCTION TO DISPLAY THE OUTPUT OF AN EXISTING TABLE RANGE LIKE COMMAM SEPERATED VALUES LIKE RANGE1,RANGE2,...

2 Answers   TVS,


Mention the different types of triggers?

0 Answers  


What is the system function to get the current user's user id?

2 Answers   HCL,


Difference between writing SQL query and stored procedure ?

15 Answers   Cognizant, Infosys, TCS, Veritas,


What do mean by xml datatype?

0 Answers  


What is in place upgrade in sql server?

0 Answers  


create procedure proc1 (@a int) as begin if @a=1 create table #temp(a1 int) else create table #temp(a1 int) end while executeing the above code it shows error like '#temp already exist' .why it shows an error?

8 Answers   IBM,


Define left outer join?

0 Answers  


Delete duplicate records from the table?(Table must have unique id)

7 Answers   TCS, Thomson Reuters,


Categories