Marketing Analytics Path · Mission 6 of 30Easy

Count unique customers

Use COUNT(DISTINCT) to find unique customers

Back to Marketing Analytics

The Brief

Sarah KimVP of Marketingmarketing-analytics

Before the board prep I'm sanity-checking row counts across our dims — quick one, how many distinct customer_ids are in `dim_customers`? Just the baseline number. Finance has its own customer count from billing and it doesn't match ours; I'll chase the actual dedupe separately, but for the board I want our table's count locked in first.

You'll practice

COUNT DISTINCTAmbiguity

Tables & columns available

dim_customersdim9 columns
ColumnTypeKey
customer_idINTPK
first_nameTEXT
last_nameTEXT
emailTEXT
signup_dateTEXT
cityTEXT
stateTEXT
ageINT
genderTEXT

Hints (3)

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

Hint 1

Use `COUNT(DISTINCT customer_id)` on `dim_customers` instead of `COUNT(*)` — DISTINCT ensures each ID is counted once

Hint 2

You can alias it: `SELECT COUNT(DISTINCT customer_id) AS total_customers FROM dim_customers`

Hint 3

The result should be a single row with one number. If you're getting multiple rows, remove any GROUP BY