Write a query to find the second-highest patient transaction amount within each healthcare facility using window functions for Health Care Solutions At Home.
Return only facilities with at least two distinct transaction amounts. Include ties for the second-highest amount.
facility_id, facility_name, transaction_id, patient_id, and transaction_amount.facility_id, transaction_amount descending, and transaction_id.| Column | Type | Description |
|---|---|---|
| facility_idPK | INT | Unique healthcare facility identifier |
| facility_name | VARCHAR(150) | Healthcare facility name |
| facility_type | VARCHAR(60) | Type of healthcare facility |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique patient transaction identifier |
| facility_id | INT | Referenced healthcare facility identifier |
| patient_id | VARCHAR(30) | Patient identifier |
| transaction_amount | DECIMAL(10,2) | Amount recorded for the patient transaction |