Your question is SQL Rank Within Departments. Start with the requirements and the two tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
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.
RANK() partitioned by department, ordering salaries from highest to lowest.| Column | Type | Description |
|---|---|---|
| department_idPK | INT | Unique department identifier |
| department_name | VARCHAR(100) | Department display name |
| Column | Type | Description |
|---|---|---|
| employee_idPK | INT | Unique employee identifier |
| employee_name | VARCHAR(100) | Employee full name |
| department_id | INT | Referenced department identifier |
| salary | NUMERIC(12,2) | Annual salary in US dollars |