HSBC wants to review compensation among active employees across its business divisions. Write a PostgreSQL query that ranks employees within each division and returns the highest and second-highest distinct annual salaries, including ties.
division_name, employee_name, annual_salary, and salary_rank, in that order.division_name, salary_rank, and employee_name in ascending order.| Column | Type | Description |
|---|---|---|
| division_idPK | INT | Unique identifier for an HSBC business division |
| division_name | VARCHAR(100) | Business division name |
| Column | Type | Description |
|---|---|---|
| employee_idPK | INT | Unique employee identifier |
| employee_name | VARCHAR(100) | Employee's full name |
| division_id | INT | References divisions.division_id |
| annual_salary | NUMERIC(12,2) | Annual salary in GBP |
| is_active | BOOLEAN | Whether the employee is currently active |