how to find nth highest salary

Answers were Sorted based on User's Feedback



how to find nth highest salary..

Answer / deepak dabi

I Think this is the best solution ever i have seen ,i
appriciate if you prove me wroong on this so,otherwise i got
all other a bit wrong ,in many cases please try this....



"SELECT distinct(sal) from emp order by sal desc limit 2,1"

Is This Answer Correct ?    1 Yes 2 No

how to find nth highest salary..

Answer / amit

Select salary
from employees
order by salary desc
limit n-1,1;

Is This Answer Correct ?    2 Yes 3 No

how to find nth highest salary..

Answer / chandra sekhar

select min(salary) from emp where salary in (select top n salary from emp order by salary desc)

Is This Answer Correct ?    1 Yes 2 No

how to find nth highest salary..

Answer / anuj somvanshi

select salary from emp where rownum=n order by salary desc;

Is This Answer Correct ?    0 Yes 1 No

how to find nth highest salary..

Answer / divya

Select Salary
From Employee
Where rowid = n
Order By Salary Desc;

Is This Answer Correct ?    0 Yes 1 No

how to find nth highest salary..

Answer / lakshmi reddy

To get nth highest salary from Employee table:
select * from Employee e where n=(select COUNT(distinct sal)
from Employee e2 where e2.Sal>e.Sal)

Is This Answer Correct ?    0 Yes 1 No

how to find nth highest salary..

Answer / sharmila shree

SELECT TOP 1 salary FROM
( SELECT DISTINCT TOP 1 salary FROM table_name
ORDER BY salary DESC )
a ORDER BY salary

here 'a' is sub query of salary

Is This Answer Correct ?    0 Yes 1 No

how to find nth highest salary..

Answer / sitakanta rath

SELECT sal FROM
(
SELECT DENSE_RANK() OVER (ORDER BY sal DESC) AS rank, sal
FROM Emp
) T2
WHERE rank=@n

Is This Answer Correct ?    0 Yes 1 No

how to find nth highest salary..

Answer / ajay kumar barik

select a.id from product a where (1= (select count(b.id)
from product b where b.id>=a.id))


It is for all database

Is This Answer Correct ?    0 Yes 2 No

how to find nth highest salary..

Answer / ankur bakliwal

I think this should work -


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 ?    0 Yes 3 No

Post New Answer

More SQL Server Interview Questions

what is the maximum size of a row? : Sql server database administration

0 Answers  


Do you know how to make remote connection in database?

0 Answers  


Explain why variables called the most powerful component of ssis?

0 Answers  


How to find out the list schema name and table name for the database?

0 Answers  


Explain how to use linked server?

0 Answers  






Questions regarding Raiseerror?

1 Answers  


Say if we have a table that contains only a single column , say OrderID, which has IDENTITY attribute defined on it. So how can we insert data in this table. I am reframing my question, that how can we make the table to increment the column "OrderID" value several times???

3 Answers  


Explain the advantages of merge replication?

0 Answers  


please tell me the query to get details of the employee having the second largest salary

11 Answers   247Customer,


What is transaction server distributed transaction?

0 Answers  


i have 4 tables.. T1, T2, T3, T4.. these tables have the same structure and they store the information entered in different years.. T1 stored 2002, T2 stored 2003, T3 stored 2004 and T4 stored 2005.. i want to copy contents in T1 to T2, T2 to T3, T3 to T4 and T4 to T1.. how do i do that? Temp tables cannot be used..

4 Answers  


What is SQL Profiler what is the use of it?

2 Answers   247Customer, Steria,


Categories