Marketing Analytics Path · Mission 10 of 25Easy

How many customers are repeat buyers?

Use HAVING to filter grouped results

Back to Marketing Analytics

The Brief

Marcus BellHead of Growthanalytics-help

How many customers have made more than one purchase? I'm trying to understand our repeat purchase rate. Just need the count of repeat buyers — don't count refunds as purchases.

You'll practice

HAVINGSubqueries

Tables available

fact_purchases

Hints (3)

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

Hint 1

First, find customers with more than one purchase: `GROUP BY customer_id HAVING COUNT(*) > 1` on `fact_purchases WHERE amount > 0`

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