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 nth highest salary

Answers were Sorted based on User's Feedback



how to find nth highest salary..

Answer / rahul tripathi

The Genral answer which can work on any SQL:-

select salary from emp e1 where (n-1)=(select count(*)
from emp where salary > e1.salary )

Rahul Tripathi

rahultripathi@inkanpur.com

Is This Answer Correct ?    249 Yes 76 No

how to find nth highest salary..

Answer / brahma

select * from table_name t1 where (n-1)=
(select count(distinct(column_name)) from table_name t2
where t2.column_name>t1.column_name)

Is This Answer Correct ?    101 Yes 47 No

how to find nth highest salary..

Answer / kavitha.r

Sorry. This one is correct


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

Is This Answer Correct ?    44 Yes 18 No

how to find nth highest salary..

Answer / udathayadav

select * from tablename.aliasname where nth=select
count(sal) from tablename where aliasname.sal<=sal

Is This Answer Correct ?    38 Yes 26 No

how to find nth highest salary..

Answer / nidhish

replace the N with wat ever number u want

select min(salary) from employee where salary in ( select
distinct top N salary from employee order by salary desc)

Is This Answer Correct ?    26 Yes 17 No

how to find nth highest salary..

Answer / debasish

select salary from table t where n-1=(select distinct count
(sal) from table t1 where t1.sal>t.sal)

Is This Answer Correct ?    19 Yes 11 No

how to find nth highest salary..

Answer / amit

select * from emp as e1 where sal (n-1) = select distinct
(count(*) from emp as e2 where e2.sal>e1.sal)

Where n is no that u want which postion's salary u want
suppose second higest means n=2

Amit

Is This Answer Correct ?    6 Yes 0 No

how to find nth highest salary..

Answer / ayush sharma

select sal from (select distinct sal from emp order by desc)
where rownum <=n minus select sal from(select distinct sal
from emp order by desc) where rownum<=n-1;

Is This Answer Correct ?    6 Yes 1 No

how to find nth highest salary..

Answer / ramakrishna

select e1.* from emp e1 where n=(select
count(distinct(e2.sal)) from emp e2 where e1.sal<=e2.sal);

Is This Answer Correct ?    5 Yes 1 No

how to find nth highest salary..

Answer / bharath

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

replace 3 by 2 for second highest...

Is This Answer Correct ?    4 Yes 0 No

Post New Answer

More SQL Server Interview Questions

How you can get the list of largest tables in a database?

0 Answers  


Do you know the cursor optimization tips?

0 Answers  


Can you please explain the difference between function and stored procedure?

0 Answers  


How do I find the port number for sql server?

0 Answers  


You want to be sure that queries in a database always execute at the maximum possible speed. To achieve this goal you have created various indexes on tables which other statement will keep the database in good condition?

0 Answers  


How do you identify a foreign key?

0 Answers  


What are the components of sql server service broker?

0 Answers  


Do you know the capabilities of cursors?

0 Answers  


Explain what are sparse columns?

0 Answers  


What is user-defined function? Explain its types i.e. Scalar and inline table value user-defined function?

0 Answers  


How to delete duplicate rows from table except one?

0 Answers  


Why foreign key column allowing null values even a parent tables reference key column not having null value..

2 Answers   IBM,


Categories