Interview Query

Upsell Transactions

19
Have you seen this question before?

We’re given a table of product purchases. Each row in the table represents an individual user product purchase.

Write a query to get the number of customers that were upsold by purchasing additional products.

Note: If the customer purchased two things on the same day that does not count as an upsell as they were purchased within a similar timeframe.

Example:

Input:

transactions table

Column Type
id INTEGER
user_id INTEGER
created_at DATETIME
product_id INTEGER
quantity INTEGER

Output:

Column Type
num_of_upsold_customers INTEGER
Next question: Interest Rates
.....
MySQL 8.0.17
Loading editor
Use Shift + Enter to run query