Write a SQL query using a window function to find the top three highest-paid employees in each department.
Use the employees and departments tables. Exclude employees without a department or salary, and break salary ties by the lower employee_id.
department_id, department_name, employee_id, employee_name, salary, and salary_rank.department_id, then salary_rank.| 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 full name |
| department_id | INT | Employee department identifier |
| salary | NUMERIC(12,2) | Annual employee salary |