Back to questions

User Shopping Sprees Amazon SQL Interview Question

User Shopping Sprees

Amazon SQL Interview Question

In an effort to identify high-value customers, Amazon asked for your help to obtain data about users who go on shopping sprees. A shopping spree occurs when a user makes purchases on 3 or more consecutive days.

List the user IDs who have gone on at least 1 shopping spree in ascending order.

Table:

Column NameType
user_idinteger
amountfloat
transaction_datetimestamp

Example Input:

user_idamounttransaction_date
19.9908/01/2022 10:00:00
15508/17/2022 10:00:00
2149.508/05/2022 10:00:00
24.8908/06/2022 10:00:00
23408/07/2022 10:00:00

Example Output:

user_id
2

Explanation

In this example, 2 is the only one who has gone on a shopping spree.

The dataset you are querying against may have different input & output - this is just an example!

Input

Output