Write a query to find the second-highest financial transaction for each department using window functions.
Return all transactions tied at the second-highest distinct amount. Exclude departments with fewer than two non-null transaction amounts.
department_name, transaction_id, transaction_amount, and transaction_rank.department_name, transaction_amount descending, then transaction_id ascending.| Column | Type | Description |
|---|---|---|
| department_idPK | INT | Unique department identifier |
| department_name | VARCHAR(100) | Department name |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique financial transaction identifier |
| department_id | INT | Department associated with the transaction |
| amount | NUMERIC(12,2) | Financial transaction amount |