Find top Nth employee from each department in terms of
salary?
Answer Posted / chandra sekhar
CREATE A EMPLOYEES TABLE WITH THE COLUMNS
EMPLOYEEID,EMPLOYEENAME,DEPARTMENT,SALARY
AND INSERT THE RECORDS INTO THE TABLE
with cte
as (
select dense_RANK() over(partition by department order by salary desc) as Rank,
employeeID,employeename,department,salary from
Employees)
select x.employeeID,
x.employeename,
x.department,
x.salary,
x.rank
from cte x
where x.Rank=2
order by x.Salary
NOTE:here i am finding 2nd highest salary from the each department
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Explain concepts of analysis services?
Explain about Joins?
How do you implement session management in SQL Server mode?
Explain how does the report manager work in ssrs?
Is it possible for a stored procedure to call itself or recursive stored procedure? How many levels of sp nesting are possible?
let's assume you have data that resides on sql server 6.5. You have to move it sql server 7.0. How are you going to do it? : Sql server database administration
What is report server project?
What are distinctive joins find as a part of sql?
Describe in brief system database.
What is a transactions?
How efficient you are in oracle and SQL server?
How to create an index on a view?
Does index speed up select statements?
How to include date and time values in sql statements?
What is 2nf in normalization?