how to find nth highest salary

Answer Posted / deven

<font color="Green" >This is long method but it works</color>

<font color="red" >step 1(this will make salary in
ascending order)</color>

<font color="blue" >create index Ind_sal on emp(salary)</color>

<font color="red" >step 2(to calculate Nth highest salary
where N=1,2,3,4.....)</color>

<font color="blue" >select distinct top N salary from emp
except
select distinct top N-1 salary from emp
</color>

<font color="red" >in some databases 2nd step may be</color>
<font color="blue" >
select distinct top N salary from emp
minus
select distinct top N-1 salary from emp</color>

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How does normalization work?

595


Explain what you mean by 3 tier architecture.

720


What is indexing in sql server with example?

589


How to connect to a sql server using odbc_connect()?

714


What program is used to store the data source file?

584






Why use triggers?

679


Explain what is use of dbcc commands?

599


What are the types of resultset?

626


What is difference between rownum and row_number?

604


What are the different subsets of sql?

1066


What are page splits? : SQL Server Architecture

639


SQL Server Architecture ?

2013


What are the benefits and tasks of object explorer? : sql server management studio

705


What is report snapshot in ssrs?

190


What is the downside of using udf?

656