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
List out the different types of locks available in sql server?
When to use Inner join & when to use subquery?
Can you pass expressions to function parameters?
What stored by the tempdb ? : sql server database administration
How can I track the changes or identify the latest insert-update-delete from a table?
What is attribute hierarchy? : sql server analysis services, ssas
Can we use max in where clause?
What is extent? Types of extents?
How to create an index on an existing table in ms sql server?
Write a query for primary key constraint with identity key word?
How do I manually uninstall an instance of sql server 2016?
How can I check that whether automatic statistic update is enabled or not?
How do you make a trace?
what are the core components of SSRS?
What is tabulation?