Marketplace Price Drops and Days from Last Drop to Sale
Last updated: November 29, 2026
Quick Overview
Using a Marketplace listing price history, find for each sold listing how many times the seller lowered the price and how many days passed between the final price drop and the sale.
Meta
November 29, 20260
0
0 solved
Using a Marketplace listing price history, find for each sold listing how many times the seller lowered the price and how many days passed between the final price drop and the sale.
Marketplace teams at Meta study whether price drop nudges actually help items sell. The interviewer checks LAG over price history to detect drops (not just changes) and correct handling of listings that sold without any drop.
What the Interviewer Expects
- Uses LAG(price) per listing ordered by change time
- Classifies a change as a drop only when the new price is lower
- Counts drops and finds the last drop timestamp per listing
- Joins to sold listings and computes days to sale
- Keeps sold listings with zero drops with a NULL gap
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 compare sale rates within 7 days of a drop versus listings that never dropped, and what bias worries you?
- How would you compute the average percent size of each drop?
- How would you detect sellers who raise and lower prices repeatedly to bump listings?
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
Tables:
listing_price_history(listing_id, price, changed_at), first row is the initial price.listings(listing_id, seller_id, sold_at),sold_atNULL if unsold....
Approach
LAG the price per listing. A drop is price < prev_price. Aggregate per listing: drop count and MAX(changed_at) among drop rows. Then join from sold listings, keeping all of them with a LEFT JOIN, ...