AnalystPath

Quarterly Sales Pivot by Product

SQLMediumMid levelWalmart~15 min

Problem

**[Asked at Walmart]**

Pivot quarterly sales so each product is one row with columns `q1`, `q2`, `q3`, `q4`.

Return `product`, `q1`, `q2`, `q3`, `q4`, ordered by product.

Tables

Example rows — the live problem includes the full dataset.

sales
sale_idproductquarterrevenue

Expected output

Your answer should return 2 rows with the columns product, q1, q2, q3, q4.

Starter code (SQL)

SELECT *
FROM 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