Measure Kindle Accessory Attach Rate Within Fourteen Days
Last updated: November 29, 2026
Quick Overview
Using orders (order_id, customer_id, order_ts) and order_items (order_id, asin, product_group), compute the share of customers who bought an accessory (KINDLE_ACCESSORY) within 14 days of their first Kindle device purchase, counting accessories in the same order.
Amazon
November 29, 20260
0
0 solved
Using orders (order_id, customer_id, order_ts) and order_items (order_id, asin, product_group), compute the share of customers who bought an accessory (KINDLE_ACCESSORY) within 14 days of their first Kindle device purchase, counting accessories in the same order.
Devices teams at Amazon track attach rate because accessories and Kindle Unlimited drive lifetime value after the device sale. The interviewer checks that you anchor on the first device purchase, apply the time window relative to that anchor, and keep non-attached buyers in the denominator.
What the Interviewer Expects
- Anchor each customer to their first device purchase with MIN
- Join accessory orders with a half-open time window relative to the anchor
- Use DISTINCT so multiple accessories do not inflate the numerator
- LEFT JOIN back to the full buyer base so the denominator is correct
- Avoid integer division in the rate
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you break attach rate down by device model and by week of purchase?
- Should accessories bought before the device count, and how would you show them?
- How would you account for customers who bought less than 14 days ago?
- How would you test whether a bundle offer on the device page increased attach rate?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
orders(order_id, customer_id, order_ts),order_items(order_id, asin, product_group); one order can hold both a device and a case.- The anchor is the customer's first Kindle device purchase. An ...
Approach
first_kindle: per customer, the minimumorder_tsamong orders containing a device.attached: join each anchor back to that customer's accessory orders inside the window;DISTINCTcustome...