Write a query to find the second-highest transaction amount for each merchant using window functions.
Use the transactions table. Treat the second-highest amount as the second distinct highest value, and exclude merchants without at least two distinct non-null amounts.
merchant_id and second_highest_amount.merchant_id in ascending order.| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| merchant_id | VARCHAR(20) | Identifier of the merchant |
| amount | NUMERIC(12,2) | Transaction amount |