logo

Back to questions

User Shopping Sprees

Hard

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 sorted by alphabetical 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.

PostgreSQL 14

Refer friends to get bonus content & cool prizes.