how to find nth highest salary

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is not null constraint?

622


What are null values in ms sql server?

558


What are types of subqueries?

558


Can you give me some DBCC command options?(Database consistency check) - DBCC CHECKDB - Ensures that tables in the db and the indexes are correctly linked.and DBCC CHECKALLOC - To check that all pages in a db are correctly allocated. DBCC SQLPERF - It gives report on current usage of transaction log in percentage. DBCC CHECKFILEGROUP - Checks all tables file group for any damage.

2030


What is the difference between ‘having’ clause and a ‘where’ clause?

551






Suppose i have a table that contains 5 columns like col1,col2...colm5.I want to import only two column through BCP utility.How to do same through BCP in sybase.

1965


How can we check the sql server version?

562


What is policy management?

581


When would you prefer to have a minimum number of indexes?

507


what are the different ways to return the rowcount of a table?

574


What is difference statement and preparedstatement?

550


what are different types of backups available in sql server? Given a particular scenario, how would you go about choosing a backup plan? : Sql server database administration

520


What is data source document?

551


Is it possible in sql table to have more than one foreign key?

612


How can you set the threshold at which sql server will generate keysets asynchronously?

565