Find top Nth employee from each department in terms of
salary?

Answer Posted / madhu sudhan g

Hi,
For suppose the table is like emp having some departments
Here i am retrieving some 'X' department employees

;WITH myTableWithRows AS (
SELECT (ROW_NUMBER() OVER (ORDER BY Salary)) as row,*
FROM emp)
SELECT empname
FROM myTableWithRows
WHERE row = Nth row and
Dept='x'
ORDER BY Salary

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a code to select distinct records without using the DISTINCT keyword.

748


What do you understand by user-defined function in the sql server and explain the steps to create and execute a user-defined function in the sql server?

600


What is sparse columns of sql server 2008?

692


What happens if the update subquery returns multiple rows in ms sql server?

690


What is reference section?

588






What do you mean by stored techniques? How would we use it?

674


Write a program using SQL queries to find a unique entry in a table.

620


Explain database normalization?

725


What is mean by clustered index and non clustered index, give syntax of creation? : sql server database administration

678


query processing

1817


What information is maintained within the msdb database?

639


What are the steps you must follow to hide sql server instances?

611


how can you check the level of fragmentation on a table? : Sql server administration

623


How to test values returned by a subquery with the in operator?

772


How to truncate the log in sql server 2012? : sql server database administration

670