AnalystPath

Quarterly Revenue by Category

SQLEasyJunior levelAmazon~15 min

Problem

**[Widely asked at Amazon and retail companies]**

Group sales into calendar quarters (Q1 = Jan–Mar, Q2 = Apr–Jun, Q3 = Jul–Sep,
Q4 = Oct–Dec) and calculate total revenue per category per quarter.

Return `quarter` ('Q1'…'Q4'), `category`, and `total_revenue`,
ordered by quarter then category.

Tables

Example rows — the live problem includes the full dataset.

category_sales
sale_idcategoryamountsale_date

Expected output

Your answer should return 6 rows with the columns quarter, category, total_revenue.

Starter code (SQL)

SELECT *
FROM category_sales;

Solve this SQL question free

Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.

Solution & explanation

Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.

Sign up free to unlock

Related SQL questions