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 / harikumar

select max(salary) as secondMax from employee where salary
<> (select max(salary) from employee)

Is This Answer Correct ?    1 Yes 0 No

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

Answer / elumalai.k

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

Is This Answer Correct ?    1 Yes 0 No

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

Answer / darshan shah

select top 1 * from (select top 2 * from emp order by sal
desc ) a order by sal asc



Plz try this.

Is This Answer Correct ?    1 Yes 0 No

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

Answer / govind.konduri

hai..

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

->here,the sub inner query finds the max sal from emp table.
->the main inner query find out the max sal that is less
than the sub inner query max sal.
->the sub query result is sent to outer query..

Is This Answer Correct ?    2 Yes 1 No

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

Answer / tulasi ravi kumar

hi,
my id is ravi106109@gmail.com

select sal from emp a
where 1=(select count(b.sal) from emp b
where a.sal<b.sal) order by sal desc;

and also dileep is write

Is This Answer Correct ?    3 Yes 3 No

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

Answer / dhaval

we have to use distinct key word there is a possibility
that two person having same salary.



select top 1 sry from (select distinct top 2 sry from emp
order by sry desc)t1 order by sry asc

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 / kavitha.r

This query is generalised query if u replace 2 by 100 ,
then you will get 100th max salary


select top 1 salary from employee where salary in( select
top 2 salary from employee order by salary desc) order by
salary asc

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 / kumar amit ranjan

To find Top 3 max Sal.... to put any number on the place of
3 to find nth max sal...


select top 3 sal from emp order by sal desc

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 / naufal basheer

select e.* from
(select row_number() over (order by salary desc) as Rno,*
from employee)e
where e.Rno = 2

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 / mahesh

Select max(sal) from emp
where id='1233' and Sal< (select max(sal) from emp)

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More SQL Server Interview Questions

hi. suppose one person goal is strong knowledge on SQL.... suggest me ...if he learns SQL SERVER or ORACLE? which is best?

7 Answers   Google, TCS, Unisys,


Explain the disadvantages of cursors?

0 Answers  


what is DTS what are tasks available

1 Answers   Wipro,


Other than truncate statement, which other command can by-pass the trigger on the tables?

0 Answers  


Which sql server table is used to hold the stored procedure script?

0 Answers  


Explain DBMS, RDBMS?

6 Answers  


how do you determine the Load performance of any query in sql server {example how do u determine performance of a select stmnt which returns Dynamically many no of records ... some times 100,1000,10000 etc., }

0 Answers   HCL, Wipro,


How to concatenate two character strings together?

0 Answers  


To which devices can a backup be created and where should these devices be located? : sql server management studio

0 Answers  


How to determine the service pack currently installed on SQL Server?

4 Answers   HCL,


Why transaction is important?

0 Answers  


How to insert multiple rows with a subquery?

0 Answers  


Categories