Compute each seller's monthly GMV from non-cancelled orders (status <> 'CANCELLED'), and its growth versus the PREVIOUS CALENDAR MONTH: mom_growth_pct = ROUND(100.0 * (gmv - prev_gmv) / prev_gmv, 1). If the seller had no GMV row in the previous calendar month (a gap month), or prev_gmv is 0, growth is NULL. Return `seller_id`, `month` ('YYYY-MM'), `gmv` (ROUND 2), `mom_growth_pct`. Only months where the seller has at least one non-cancelled order appear. Order by `seller_id`, `month`.
| Column | Type |
|---|---|
| order_id | INTEGER |
| seller_id | INTEGER |
| order_date | DATE |
| gmv | REAL |
| status | TEXT |
| order_id | seller_id | order_date | gmv | status |
|---|---|---|---|---|
| 1 | 1 | 2026-01-05 | 600 | DELIVERED |
| 2 | 1 | 2026-01-20 | 400 | DELIVERED |
| 3 | 1 | 2026-02-11 | 1500 | DELIVERED |
| 4 | 1 | 2026-03-02 | 1200 | SHIPPED |
| 5 | 1 | 2026-03-15 | 500 | CANCELLED |
| 6 | 2 | 2026-01-09 | 800 | DELIVERED |
| 7 | 2 | 2026-03-03 | 1000 | DELIVERED |
| 8 | 2 | 2026-04-18 | 1100 | DELIVERED |
| seller_id | month | gmv | mom_growth_pct |
|---|---|---|---|
| 1 | 2026-01 | 1000 | NULL |
| 1 | 2026-02 | 1500 | 50 |
| 1 | 2026-03 | 1200 | -20 |
| 2 | 2026-01 | 800 | NULL |
| 2 | 2026-03 | 1000 | NULL |
| 2 | 2026-04 | 1100 | 10 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
‹ Biggest Single-Day Chart Climb · Median Order Value per Category (No MEDIAN) ›
{{ totalCount }} questions in the style asked at Amazon, Microsoft, Google, Meta, Flipkart and more — {{ hardPct }}% Hard. Write SQL in a real database engine in your browser, run it on sample data, then evaluate against hidden tests.
Company tags show where this type of question is commonly reported in interviews. Questions, data and solutions are written by TechTown.
{{ cur.statement }}
No submissions yet. Press Evaluate to submit your query.
{{ solutionSql }}
{{ out.error }}
You have solved your 3 free questions — nice work! Log in (free) to unlock all 150 questions, keep your streak and appear on the leaderboard.