order_lines has revenue rows (category, sales_year, revenue); a category can have several rows for the same year. Total revenue per category and year, then for each category-year whose previous calendar year (sales_year - 1) also has revenue for that category, compute yoy_growth_pct = 100 * (current - previous) / previous. Years without the immediately preceding year are not reported. Output columns: category, sales_year, yoy_growth_pct (rounded to 2 decimals). Order by category, then sales_year.
| Column | Type |
|---|---|
| category | TEXT |
| sales_year | INTEGER |
| revenue | REAL |
| category | sales_year | revenue |
|---|---|---|
| Furniture | 2024 | 100 |
| Furniture | 2025 | 120 |
| Furniture | 2026 | 150 |
| Decor | 2024 | 80 |
| Decor | 2025 | 100 |
| category | sales_year | yoy_growth_pct |
|---|---|---|
| Decor | 2025 | 25 |
| Furniture | 2025 | 20 |
| Furniture | 2026 | 25 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
{{ 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.