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
How to use group functions in the select clause in ms sql server?
What is executereader?
Can you name a few encryption mechanisms in sql server?
Help!!!!!!!!!!!! My database has gone offline, it is highlighted as 'Suspect'. Foolishly, i haven't got a recent back up. Is there a way of quickly restoring the database? Thank you
What are data regions?
How does using a separate hard drive for several database objects improves performance right away?
What is an execution plan?
Tell me what is difference between view and materialized view?
What are the different type of replication in sql server?
How do I debug a stored procedure in sql server?
What is ddl command?
Which are new data types introduced in sql server 2008?
how you can move data or databases between servers and databases in sql server? : Sql server administration
What type of Index will get created after executing the above statement?
Explain the difference between HTTP and HTTPS in database?