This SQL tutorial will show how the SQL Server window function DENSE_RANK() can be leveraged to get the nth highest record from a table. The SQL Server DENSE_RANK() function attaches a rank with each row inside the result set partition. The DENSE_RANK() method, in contrast to the RANK...
-- To get nth Highestselect distinct salary from (select salary,dense_rank() over(order by salary desc) as sal from Table )where sal = &n--To get nth Lowest selectdistinct salaryfrom (select salary,dense_rank() over(order by salary) as sal from Table ) where= &n sal Was this...