Search ⌘K
Apple
Apple

Interview Core Track · Hard · 35 min

9. Follow-Up AirPod Percentage

The Apple Customer Retention Data Science team needs your help to investigate buying patterns related to AirPods and iPhones. Write a SQL query to determine ...

Interview Core Track
Hard
35 min
aggregation
filtering

Company labels are directional practice context, not official interview guidance.

Timer 00:00
Back to practice

Objective

Practice aggregation through a Apple-tagged business scenario.

Approach

Use this track to improve speed, edge-case handling, and accuracy under timed conditions.

Company context

Company labels are directional practice context, not official interview guidance.

Prereq: query basics
Prereq: filtering

The Apple Customer Retention Data Science team needs your help to investigate buying patterns related to AirPods and iPhones. Write a SQL query to determine the percentage of buyers who bought AirPods directly after they bought iPhones. Round your answer to a percentage (i.e. 20 for 20%, 50 for 50) with no decimals. transactions Table: Column Name Type -------------------- transaction_id integer customer_id integer product_name varchar transaction_timestamp datetime transactions Example Input: transaction_id customer_id product_name transaction_timestamp ---------------------------------------------------------------------- 1 101 iPhone 08/08/2022 00:00:00 2 101 AirPods 08/08/2022 00:00:00 5 301 iPhone 09/05/2022 00:00:00 6 301 iPad 09/06/2022 00:00:00 7 301 AirPods 09/07/2022 00:00:00 Example Output: follow_up_percentage ---------------------- 50 Of the two users, only user 101 bought AirPods after buying an iPhone. Note that we still count user 101, even though they bought both an iPhone and AirPods in the same transaction. We can't count customer 301 since they bought an iPad in between their iPhone and AirPods. Therefore, 1 out of 2 users fit the problem's criteria. For this example, the follow-up percentage would be 50%. Solution: -- refer the HARD questions folder for the solution. ---

Pro question
This is a Pro question

Upgrade to Pro to unlock this prompt, the SQL workspace, and all 254 problems.

Upgrade to Pro — unlock all 254 problems
Editor
SQL workspace

Run queries against the protected question data, then submit once the result shape looks right.

Sign in to run SQL

Create a free account or sign in before running queries against protected question data.