Given a table of user transactions, write a query to detect potential duplicate payments, defined as transactions by the same user for the same amount within a 5-minute window.
Return each qualifying transaction pair once. Exclude pairs with different users, different amounts, missing comparison values, or time gaps greater than five minutes.
user_id, both transaction IDs, both timestamps, amount, and elapsed_seconds.user_id, first timestamp, second timestamp, and transaction IDs.| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| user_id | INT | Identifier of the user who made the payment |
| amount | NUMERIC(12,2) | Payment amount |
| transaction_ts | TIMESTAMPTZ | Timestamp when the payment occurred |