Share of Customers Whose First Order Included Large Furniture
Last updated: November 29, 2026
Quick Overview
Using orders and order_items tables, compute for each month of first purchase the share of new customers whose first order contained at least one item from the large-parcel furniture class.
Wayfair
November 29, 20260
0
0 solved
Using orders and order_items tables, compute for each month of first purchase the share of new customers whose first order contained at least one item from the large-parcel furniture class.
Whether a customer starts with a sofa or with a throw pillow changes their delivery experience and repeat behavior, so Wayfair analytics teams cut cohorts this way constantly. The screen checks window functions for 'first order', correct handling of ties, and avoiding double counting when an order has many items.
What the Interviewer Expects
- Identifies each customer's first order with ROW_NUMBER or MIN
- Breaks ties deterministically when two orders share a timestamp
- Collapses items to an order-level flag before averaging
- Groups by first-order month
- Excludes cancelled orders after clarifying
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 extend this to compare 12-month repeat rate between the two groups?
- Some 'first orders' are actually returning customers with a new account. How would you detect that?
- How would you write this in BigQuery for a table with billions of order items?
- Would you count an order that was fully cancelled?
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
Assume orders(order_id, customer_id, placed_at, status) and order_items(order_id, sku, product_class, qty), where product_class = 'large_parcel' marks items that ship freight or white-glove. Cla...
Approach
- Rank each customer's valid orders by time to find the first.
- Build an order-level flag
has_largewithMAX(CASE ...)so an order with three large items counts once. - Join the flag to first ...