Marketing Analytics Path · Mission 4 of 25Starter

Where are our customers?

Use GROUP BY with ORDER BY to find top values

Back to Marketing Analytics

The Brief

Alex ChenMarketing Managerslack-dm

We're thinking about running a geo-targeted campaign. Can you show me which states have the most customers? Just the top 5 would be great — state and count.

You'll practice

GROUP BYORDER BYLIMIT

Tables available

dim_customers

Hints (3)

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

Hint 1

Group customers by `state` using `GROUP BY state`, then count each group with `COUNT(*)`

Hint 2

Sort by count descending with `ORDER BY ... DESC` and use `LIMIT 5` to get only the top 5 states

Hint 3

Alias your count column as `customer_count`: `COUNT(*) AS customer_count`