001Level 1

Chapter 7 · CTEs

04. Monthly Revenue Report with CTE

Hard40 XPE-Commerce

Build a monthly revenue report using a Common Table Expression. The CTE should compute monthly revenue and order count. The main query should return the month, revenue, order count, and the month-over-month revenue change, sorted by month. Format months as YYYY-MM.

Tables

  • PKidINT
  • FKcustomer_id→ customers.idINT
  • order_dateTEXT
  • statusTEXT
  • total_amountREAL

Need help?

Ask Sol

AI tutor — looks at your current query and nudges you, without spoiling the answer.

Solution

Try the hints first — solving it yourself is what makes it stick.

Peek at the solution?

You can still earn the XP afterwards by submitting a working query — but you'll learn more if you give it one more try.