how to find nth highest salary

Answer Posted / vinay upadhyay

These are tested queries to find Nth highest salary

Select distinct(sal) From employee emp Where n =
( Select Count(Distinct y.sal) From employee y Where y.sal
>=emp.sal)

OR

select distinct(salary) from employee order by salary desc
limit n-1,1

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the differences between char and varchar in ms sql server?

660


what are defaults? : Sql server database administration

598


What is logon trigger?

623


How to encrypt Strored Procedure in SQL SERVER?

642


How to execute a sql statement using odbc_exec()?

653






Can we store videos inside the sql server table?

620


What is the name of the system variable that returns the number of rows affected by a SQL statement?

659


What is the significance of master, tempdb and model databases?

623


Explain different types of BACKUPs avaialabe in SQL Server? Given a particular scenario, how would you go about choosing a backup plan?

667


How do triggers work?

613


What are the characteristics of modern DBMS?

700


How to Insert multiple rows with a single insert statement?

635


Can sql servers linked to other servers?

633


We need to perform what steps in the following order to work with a cursor?

810


Difference between Sql server reporting services and Crystal reports?

132