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
How to enter date and time literals in ms sql server?
how you can move data or databases between servers and databases in sql server? : Sql server administration
When I run the sql server 2000 setup, it just hangs. What do I do?
how many bits ip address consist of? : Sql server database administration
What are the different types of sub-queries?
You want to use a perspective in an mdx query. How do you select the perspective?
You have a stored procedure, which execute a lengthy batch job. This stored procedure is called from a trigger you do not want to slow the data entry process you do not want trigger to wait for this batch job to finish before it completes itself what you can do to speed up the process?
How to generate random numbers with the rand() function in ms sql server?
How to convert a numeric expression from one data type to another?
Mention the 3 ways to get a count of the number of records in a table.
Tell me extended events in sql server 2008?
Differentiate between sql temp table vs table variable?
When cursors are useful?
How to insert new line characters into strings?
How many tables can be joined in SQL Server?