Compute Each Seller's Share of Category GMV for the Month
Last updated: November 29, 2026
Quick Overview
Using order_lines (order_id, asin, seller_id, quantity, unit_price, line_status, order_date) and products (asin, category), compute each seller's October 2026 GMV per category and their share of that category's total, excluding cancelled lines.
Amazon
November 29, 20260
0
0 solved
Using order_lines (order_id, asin, seller_id, quantity, unit_price, line_status, order_date) and products (asin, category), compute each seller's October 2026 GMV per category and their share of that category's total, excluding cancelled lines.
Marketplace category teams at Amazon watch seller concentration to spot categories dominated by one seller and to size opportunities for new selling partners. The interviewer checks a join to the product dimension, correct GMV filters, and a window SUM for the share instead of a second join.
What the Interviewer Expects
- Join order lines to products to get the category
- Exclude cancelled lines before aggregating
- Aggregate to seller and category, then use SUM OVER PARTITION BY category for the denominator
- Use a half-open date range for the month
- Order output so the biggest sellers appear first within each category
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 compute a concentration index such as HHI per category from this?
- Should Amazon first-party retail be treated as a seller here, and how would you label it?
- How would you handle returns that happen after the month closes?
- How would you show the top 3 sellers and group everyone else into Other?
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
order_lines: one row per line with quantity, unit price, seller and status. GMV = quantity x unit_price for non-cancelled lines; returns are ignored for this cut.products(asin, category): one...
Approach
Aggregate GMV per category and seller in a CTE, then divide each row by SUM(gmv) OVER (PARTITION BY category). The window avoids a second aggregation and join for category totals. Filtering cancelle...