Write a query to find the top three highest-paying departments using a window function.
Use average employee salary to define highest-paying. Include departments whose rank is among the top three, allowing ties to share a rank.
department_name, average_salary, and department_rankdepartment_rank, then department_name| Column | Type | Description |
|---|---|---|
| department_idPK | INT | Unique department identifier |
| department_name | VARCHAR(100) | Department name |
| Column | Type | Description |
|---|---|---|
| employee_idPK | INT | Unique employee identifier |
| employee_name | VARCHAR(100) | Employee name |
| department_id | INT | Employee department identifier |
| salary | INT | Annual employee salary |