Find top Nth employee from each department in terms of
salary?
Answer Posted / sandeep modapathi
SELECT DISTINCT MIN(SALARY),DEPARTMENT
FROM (SELECT TOP ((SELECT COUNT(DISTINCT DEPARTMENT) FROM
EMPLOYEE)*@N)
SALARY,DEPARTMENT
FROM EMPLOYEE ORDER BY SALARY DESC
) AS CUR1 GROUP BY DEPARTMENT
try it out ..................
it will show you the Nth top salary for each department
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
Define normalisation?
What is an example of a primary key?
What are the aggregate and scalar functions?
How should i optimize the time for execution of stored procedure having single input and many output from the different tables?
What is the difference between rank and dense_rank?
Difference between connected and disconnected database in .net with sql server?
Can you force a query to use a specific index?
How does normalization work?
if no size is defined while creating the database, what size will the database have? : Sql server administration
What are the basic functions for master, msdb, model, tempdb and resource databases? : SQL Server Architecture
What is difference between group by and having?
What is RAID? What are the different types of RAID configurations?
Can I save my report as html, excel or word? : sql server management studio
Explain the truncate command? : SQL Server Architecture
Can an entity have two primary keys?