Report Month-over-Month Revenue Growth for Each Amazon Marketplace

Last updated: November 29, 2026

Quick Overview

For each marketplace (US, UK, DE, JP and so on), compute monthly revenue, the previous month's revenue, and the percentage change using LAG.

Amazon
Data Manipulation (SQL/Python)
Data Scientist
Amazon
November 29, 2026
Data Scientist
Phone Screen
Data Manipulation (SQL/Python)
Easy

0

0

0 solved


For each marketplace (US, UK, DE, JP and so on), compute monthly revenue, the previous month's revenue, and the percentage change using LAG.

A short phone-screen query typical for Amazon retail finance and BIE-style analytics work. The interviewer checks LAG with the right partition, safe division, and whether you notice that the previous row is not always the previous month.

What the Interviewer Expects
  • Aggregate to marketplace and month first
  • Partition LAG by marketplace and order by month
  • Guard against division by zero with NULLIF
  • Recognize that missing months make LAG compare non-adjacent months
  • Keep the currency consistent across marketplaces
Key Topics to Cover
LAG
PARTITION BY
growth rate
NULLIF
month gaps
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you compute year-over-year growth instead?
  • How would you fill months where a new marketplace had no sales?
  • How would you rank marketplaces by growth each month?
  • What changes if revenue is stored in local currency?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

Table orders(order_id, marketplace, order_ts, revenue_usd), one row per order, already converted to USD. Questions: is revenue net of refunds (assume this column is net), and should partial current ...

Approach
  1. Sum revenue by marketplace and month.
  2. LAG(revenue) OVER (PARTITION BY marketplace ORDER BY month) gives the prior row's revenue for that marketplace.
  3. Growth is (revenue - prev) / prev, gu...

Submit Your Answer
Markdown supported