Marketing Analytics Path · Mission 10 of 30Easy

How many customers are repeat buyers?

Use HAVING to filter grouped results

Back to Marketing Analytics

The Brief

Marcus BellHead of Growthanalytics-help

Quick one for the quarterly deck — what's our repeat purchase rate? I'm writing the retention slide and I need one number: how many customers have made more than one purchase (refunds don't count). The CMO cares about the percentage, but if you give me the count I can compute the rest.

You'll practice

HAVINGSubqueries

Tables & columns available

fact_purchasesfact7 columns
ColumnTypeKey
purchase_idINTPK
customer_idINTFK → dim_customers
purchase_dateTEXT
amountREAL
product_categoryTEXT
campaign_idINTFK → dim_campaigns
coupon_codeTEXT

Hints (3)

Each hint you reveal reduces the XP you can earn. Try the query first.

Hint 1

Think about how to group purchases per customer, then keep only the customers with more than one. Refunds shouldn’t count as a purchase — so watch for negative amounts in `fact_purchases`.

Hint 2

That gives you the repeat buyers — but you need to COUNT them. Wrap it in a subquery: `SELECT COUNT(*) FROM (...) sub`

Hint 3

Alias the final result: `SELECT COUNT(*) AS repeat_customers FROM (...) sub` — the subquery needs an alias like `sub` after the closing parenthesis