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
What are the difference between clustered and a non-clustered index?
What is in place upgrade in sql server?
Describe how to use the linked server?
What are the differences between INNER JOIN, LEFT JOIN and RIGHT JOIN in SQL Server?
How to count duplicated values in a column in ms sql server?
Explain the dirty pages?
How to get a list of table columns using the "sp_columns" stored procedure in ms sql server?
What is the use of sql profiler in sql server 2012?
What are the different acid properties?
How you can add messages to the nt event log from within a stored procedure?
Which is better statement or preparedstatement?
While migrating Microsoft SQL Server 2008 database to SQL Azure, what can be done to ensure the database connectivity does not degrade?
How check triggers in sql server?
Explain boyce and codd normal form(bcnf)?
Can sub report data source be different from that of the parent report?