Write a SQL query using window functions to rank transactions within each department by amount and return the top 3 per department.
Ties should receive the same rank, so a department may return more than three rows. Exclude transactions that do not belong to a defined department.
transaction_id, department_name, amount, and amount_rank.| Column | Type | Description |
|---|---|---|
| department_idPK | INT | Unique department identifier |
| department_name | VARCHAR(100) | Department name |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| department_id | INT | Department associated with the transaction |
| amount | NUMERIC(12,2) | Transaction amount |