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 a table called, if it has neither cluster nor non-cluster index? What is it used for?

691


Write a sql query to sort on different column name according to the parameters passed in the function?

612


What is model database? : SQL Server Architecture

662


Why should one not prefix user stored procedures with ‘sp_’?

695


Define compound operators?

603






Is it important for a database administrator to understand the operating system and file access?

597


When would you use it?

675


How many types of schemas are there?

605


How to Improve the performencs of SQL Server 2005 exclude stored Procedure and Indexes?

1656


Do you know hot add cpu in sql server 2008?

628


Explain indexing and what are the advantages of it?

621


What is the difference between a fill factor of 100 and 0?

620


What will happen if a column containing char type data is changed to the nchar data type?

704


What are the different types of upgrades that can be performed in sql server?

797


What is user-defined scalar function?

635