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


How to find the second largest salary in the emp database and
also How to find 3rd,4th and so on ........ in the emp database

plz mail the answer @ mak2786@gmail.com

Answers were Sorted based on User's Feedback



How to find the second largest salary in the emp database and also How to find 3rd,4th and so on ....

Answer / your name

Forget everything...Here it goes..in a simple way...

Select salary from tbl_name a where
n = (Select count(distinct(count(*))) from tbl_name b
where b.salary>=a.salary)

Substitute you value for n. thats all.

Is This Answer Correct ?    0 Yes 1 No

How to find the second largest salary in the emp database and also How to find 3rd,4th and so on ....

Answer / aditya kumar bisoi

SELECT EmpId,Salary
FROM(SELECT ROW_NUMBER() OVER(ORDER BY Salary Desc) AS [ROW_NUMBER],* FROM (SELECT DISTINCT Salary,Empid FROM EMPDetails)Emp)Emp1
WHERE ROW_NUMBER BETWEEN 2 AND 5

Is This Answer Correct ?    0 Yes 1 No

How to find the second largest salary in the emp database and also How to find 3rd,4th and so on ....

Answer / prasant palo

with ttble as
(
select top 3 empid,empname,empsalary
from
emptable
order by empsalary desc
)
-- above will create a common table expression with name
--ttable
-- to know about it search for commontable expression
select top 1 empid,empname,empsalary
from
ttable
order by empsalary asc

Is This Answer Correct ?    2 Yes 5 No

How to find the second largest salary in the emp database and also How to find 3rd,4th and so on ....

Answer / prashant narvekar

1. solution taken as std_id instead of salary
select max( b.std_id) from std_info a
inner join std_info b on a.std_id <> b.std_id
where a.std_id > b.std_id

2. solution
select max(std_id) from std_info
where std_id < ( select max(std_id) from std_info)

Is This Answer Correct ?    2 Yes 5 No

How to find the second largest salary in the emp database and also How to find 3rd,4th and so on ....

Answer / savita vishwakarma

select max(sal)
from (select rownum
from emp
order by sal desc)
where rownum=2

Is This Answer Correct ?    2 Yes 5 No

How to find the second largest salary in the emp database and also How to find 3rd,4th and so on ....

Answer / vishakha shrivastava

for second largest salary
Select * from emp a where 2=(select count(*) from emp b
where a.sal<=b.sal)

Above mentioned query can also be used for 3 ,4 ..n

Select * from emp a where 3=(select count(*) from emp b
where a.sal<=b.sal)

Is This Answer Correct ?    2 Yes 5 No

How to find the second largest salary in the emp database and also How to find 3rd,4th and so on ....

Answer / kaku

Yeh Saare answer galat hain

Is This Answer Correct ?    0 Yes 3 No

How to find the second largest salary in the emp database and also How to find 3rd,4th and so on ....

Answer / vinay singh

To find any number of Salary..

Select * From Table E1 Where
(n-1) = (Select Count(Distinct(E2.Sal)) From Table E2
Where E2.Sal> E1.Sal)


**Vinay Singh

Is This Answer Correct ?    8 Yes 12 No

How to find the second largest salary in the emp database and also How to find 3rd,4th and so on ....

Answer / balaji

TO FIND THE N-1th HIGHEST SALARY IN EMP TABLE

Select Min(salary) from emptable where salary not in(Select
Min(salary) from emptable)

Is This Answer Correct ?    0 Yes 4 No

How to find the second largest salary in the emp database and also How to find 3rd,4th and so on ....

Answer / subhranghshu bhattacharjee

another way u can find 2nd largest salary,3rd largest
salary ... so on

select sal from(select sal from emp order by sal desc)
where rownum<3
minus
select sal from(select sal from emp order by sal desc)
where rownum<2

only change rownum to find various largest salary

Subhranghshu Bhattacharjee

Is This Answer Correct ?    4 Yes 9 No

Post New Answer

More SQL Server Interview Questions

Do you know what is a linked server in sql server?

0 Answers  


What are points to remember while using the fillfactor argument?

0 Answers  


How do I view a procedure in sql server?

0 Answers  


Write an SQL query if u want to select the data from one block which intern reflects in another block ? thanx,do reply

1 Answers   Covansys,


Do you know what is similarity and difference between truncate and delete in sql?

0 Answers  


Is it possible to replicate data from sql server to oracle? : sql server replication

0 Answers  


How to create a local temporary stored procedure?

0 Answers  


What is an index in a database?

0 Answers  


What are the differences between having and where clause.

0 Answers  


Explain what are the different index configurations a table can have?

0 Answers  


What is normalization? Explain its different types?

0 Answers   GE, Maveric,


What does man by sql wildcard characters in sql server?

0 Answers  


Categories