Munich Reinsurance America needs a workforce report identifying employees whose salary is at rank 2 within their department. Write a PostgreSQL query that joins employee records to department names and ranks salaries independently for each department.
Requirements
- Use
RANK() partitioned by department, ordering salaries from highest to lowest.
- Return every employee whose salary has rank 2. Employees tied at the second salary level must all be included.
- Exclude employees without a matching department and order the results by department name, salary descending, and employee name.