001Level 1

Chapter 7 · CTEs

06. Repeat Purchase Rate by Month

Hard40 XPE-Commerce

Calculate the repeat purchase rate for each month. A 'repeat purchaser' is a customer who placed more than one order that month. For each month (YYYY-MM), show total unique customers, repeat customers, and the repeat rate as a percentage (rounded to 1 decimal). Sort by month.

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.