how to find nth highest salary

Answers were Sorted based on User's Feedback



how to find nth highest salary..

Answer / sunil patel

with cte as (
SELECT DENSE_Rank() OVER(PARTITION BY ecc_dm_id_dep ORDER
BY ecc_gross_simple DESC) AS RowID,
*
FROM emp_curr_company
)
SELECT *
FROM cte
WHERE RowID = 2

Is This Answer Correct ?    2 Yes 2 No

how to find nth highest salary..

Answer / jayakumar

please try this....

this is very usefull to you

select colunm_name from (select distinct(column_name) from
table_name where column_name is NOT NULL order by desc)
where rownum=n;

Is This Answer Correct ?    0 Yes 0 No

how to find nth highest salary..

Answer / anand patel.

It is a very generic and easy way to find the Nth higest
salary with there employee/s name.

select * from emp where salary =
(select max(salary) from emp where salary in
(select top (select (count(*)-(n-1))from emp) salary
from emp order by salary))

Is This Answer Correct ?    2 Yes 2 No

how to find nth highest salary..

Answer / satesh naidu

select * from emp e1 where &n=(select count(distinct
(e2.sal) from emp e2 where e.sal>e1.sal)

Hai friends try this.u will get nth highest salary.

Is This Answer Correct ?    0 Yes 0 No

how to find nth highest salary..

Answer / guru

select max(salary) from Employee where salary not in(select
top (n-1) salary from Employee order by salary desc)

Is This Answer Correct ?    0 Yes 0 No

how to find nth highest salary..

Answer / affu

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

Is This Answer Correct ?    1 Yes 1 No

how to find nth highest salary..

Answer / aman kaushal

select salary from customer order by salary desc limit n,1;

here n is the array value 1st highest value starts with 0
value and then 1.

e.g

find the 2nd highest salary.

select salary from customer order by salary desc limit 1,1;

Is This Answer Correct ?    1 Yes 1 No

how to find nth highest salary..

Answer / rabi

SELECT A.SAL
FROM TABLE A WHERE &N=(SELECT COUNT(DISTINCT(B.SAL))
WHERE A.SAL<=B.SAL);

Is This Answer Correct ?    0 Yes 0 No

how to find nth highest salary..

Answer / kunal gupta

select top 1 sal from (select top n sal from tbl_master
group by sal order by sal desc)m order by sal

This answer is easiest and 100% tested

Is This Answer Correct ?    1 Yes 1 No

how to find nth highest salary..

Answer / kiran k s

select distinct(salary) from table t1
where 4=(select count(distinct(salary))from table t2
where t2.salary >= t1.salary);

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

How the authentication mode can be changed?

0 Answers  


How do I edit a stored procedure in sql server?

0 Answers  


system date format is "yy-mm-dd" "select getdate()" ----> 2009-01-24 20:03:28.513 if i write "select dateadd(dd,2,getdate()) ".it returns "2009-01-26 19:59:38.340"...my question is dat could it be possible to retrive da date in da format "26 jan 2009 ...."??

8 Answers  


Explain what are db_options used for?

1 Answers   InterGraph,


What is the optimal disk configuration for a database server and what raid configurations would you use if budget is not a constraint?

0 Answers  






How can I track the changes or identify the latest insert-update-delete from a table?

0 Answers  


What are the properties of the transactions?

0 Answers  


How do you identify a foreign key?

0 Answers  


What are translations and its use? : sql server analysis services, ssas

0 Answers  


What is the difference between sql server 2000 object owner and sql server 2005 schema? : sql server database administration

0 Answers  


Do you know what are the ways available in sql server to execute sql statements?

0 Answers  


Tell me what are the essential components of sql server service broker?

0 Answers  


Categories