Back to questions

First Transaction Etsy SQL Interview Question

First Transaction

Etsy SQL Interview Question

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

Assume you're given a table containing Etsy user transactions. Write a query that retrieves the customers whose first transaction was valued at $50 or more. Output the total number of users who meet this criteria.

Instructions:

  • To determine the first transaction for each user, use the field.
  • Take into account scenarios where a user had multiple transactions on the same day. Use a specific function (we can't give too much away 😉) to handle these cases and correctly identify the first transaction.

Effective June 14th, 2023, the solution and hints have been revised.

Table:

Column NameType
transaction_idinteger
user_idinteger
spenddecimal
transaction_datetimestamp

Example Input:

transaction_iduser_idspendtransaction_date
75927411149.5002/03/2022 00:00:00
85037111151.0003/15/2022 00:00:00
61534814536.3003/22/2022 00:00:00
137424156151.0004/04/2022 00:00:00
24847515687.0004/16/2022 00:00:00

Example Output:

users
1

Explanation:

Among all the users, only user ID 156 had their first transaction valued at over $50.

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

Input

Output