Write a SQL query using window functions to find the second-highest transaction amount for each customer within a specific month.
Use May 2024 as the target month. Treat the second-highest amount as the second distinct amount, exclude NULL amounts, and exclude customers without at least two distinct transactions in the month.
customer_id, second_highest_amountcustomer_id ascending| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| customer_id | INT | Identifier of the customer making the transaction |
| transaction_date | DATE | Date on which the transaction occurred |
| amount | DECIMAL(12,2) | Transaction amount |