transfers has one row per payment (payment_id, payer_id, payee_id, amount, paid_at). A payment is a suspected duplicate when an earlier payment with the same payer_id, payee_id and amount was made at most 5 minutes (300 seconds, inclusive) before it. For each suspected duplicate, return the payment it duplicates: the most recent such earlier payment. Output columns: payment_id, duplicate_of. Order by payment_id ascending.
| Column | Type |
|---|---|
| payment_id | INTEGER |
| payer_id | INTEGER |
| payee_id | INTEGER |
| amount | REAL |
| paid_at | TIMESTAMP |
| payment_id | payer_id | payee_id | amount | paid_at |
|---|---|---|---|---|
| 1 | 10 | 20 | 50 | 2026-01-01 10:00:00 |
| 2 | 10 | 20 | 50 | 2026-01-01 10:02:00 |
| 3 | 10 | 20 | 75 | 2026-01-01 10:03:00 |
| 4 | 11 | 20 | 50 | 2026-01-01 10:01:00 |
| payment_id | duplicate_of |
|---|---|
| 2 | 1 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
‹ Regional Support Leaders · Dormant Then Returning Members ›
{{ totalCount }} questions in the style asked at Amazon, Microsoft, Google, Meta, Flipkart and more — {{ hardPct }}% Hard. Write SQL in a real database engine in your browser, run it on sample data, then evaluate against hidden tests.
Company tags show where this type of question is commonly reported in interviews. Questions, data and solutions are written by TechTown.
{{ cur.statement }}
No submissions yet. Press Evaluate to submit your query.
{{ solutionSql }}
{{ out.error }}
You have solved your 3 free questions — nice work! Log in (free) to unlock all 150 questions, keep your streak and appear on the leaderboard.