Marketing Analytics Path · Mission 8 of 30Easy

How many customers never bought anything?

Use LEFT JOIN to find non-matching rows

Back to Marketing Analytics

The Brief

Sarah KimVP of Marketingmarketing-analytics

How many customers in our database have never made a purchase? Need a count for the re-engagement push — planning meeting's tomorrow morning, so before EOD if you can. Just the number.

You'll practice

LEFT JOINIS NULL

Tables & columns available

dim_customersdim9 columns
ColumnTypeKey
customer_idINTPK
first_nameTEXT
last_nameTEXT
emailTEXT
signup_dateTEXT
cityTEXT
stateTEXT
ageINT
genderTEXT
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

Use a `LEFT JOIN` from `dim_customers` to `fact_purchases` on `customer_id` — this keeps all customers, even those with no purchases

Hint 2

After the LEFT JOIN, customers with no purchases will have NULL in the fact_purchases columns. Filter with `WHERE p.purchase_id IS NULL`

Hint 3

One row out, one number — the count of unmatched customer rows. Alias it so Sarah's slide reads cleanly.