Back to questions

Repeat Purchases on Multiple Days Stitch Fix SQL Interview Question

Repeat Purchases on Multiple Days

Stitch Fix SQL Interview Question

This is the same question as problem #7 in the SQL Chapter of Ace the Data Science Interview!

Assume you are given the table below containing information on user purchases. Write a query to obtain the number of users who purchased the same product on two or more different days. Output the number of unique users.

PS. On 26 Oct 2022, we expanded the data set, thus the official output may vary from before.

Table:

Column NameType
user_idinteger
product_idinteger
quantityinteger
purchase_datedatetime

Example Input:

user_idproduct_idquantitypurchase_date
5363223601/11/2022 12:33:44
82735853502/20/2022 14:05:26
5363223503/02/2022 09:33:28
53614351003/02/2022 08:40:00
82724524504/09/2022 00:00:00

Example Output:

repeat_purchasers
1

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

Input

Output