Suspicious Card Activity

Start Timer

0:00:00

Upvote
0
Downvote
Save question
View comments

We’re given a card_payments table where each row is a single card payment with the user, the country the payment was made in, and the timestamp. Write a query to find the user_id of every user who made at least three payments in three different countries within any two-hour window.

Assume payment IDs are unique and user IDs, countries, and timestamps are non-null. Include payments exactly two hours after the first. The two-hour window is measured from the first payment in the group, so the other two payments must fall within two hours of it. A distinct country per payment is required, so three payments across only two countries do not qualify.

Input:

card_payments table

Column Type
payment_id INTEGER
user_id INTEGER
country VARCHAR
created_at DATETIME

Output:

Column Type
user_id INTEGER

Adapted from an interview report · 2026-05-30. Details and assumptions have been adapted for practice; this is not a verbatim interview question.

.
.
.
.
.


Comments

Loading comments