Retail Banking Operations Path · Mission 4 of 30Starter

Active deposit customers by state

JOIN with COUNT DISTINCT to avoid double-counting

The Brief

Sarah ReyesCustomer Insights Leadretail-ops

Planning the Q2 direct-mail drop. I need the count of active deposit customers by state. Deposit = Checking or Savings (look at `retail_products.subcategory`). Active = account status is `Open`. Show `state` and a count column called `n_customers`, sorted highest to lowest. Distinct customers — not accounts. One person can hold both a checking and a savings.

You'll practice

JOINGROUP BYCOUNT DISTINCT

Tables & columns available

retail_customersdim13 columns
ColumnTypeKey
customer_idINTPK
household_idTEXT
first_nameTEXT
last_nameTEXT
date_of_birthTEXT
stateTEXT
segmentTEXT
fico_currentINT
estimated_incomeREAL
kyc_riskTEXT
acquisition_channelTEXT
onboarded_dateTEXT
statusTEXT
retail_accountsdim13 columns
ColumnTypeKey
account_idINTPK
customer_idINTFK → retail_customers
product_idINTFK → retail_products
branch_idINTFK → retail_branches
open_dateTEXT
close_dateTEXT
statusTEXT
ownership_typeTEXT
interest_rateREAL
original_balanceREAL
credit_limitREAL
fico_at_origINT
maturity_dateTEXT
retail_productsdim10 columns
ColumnTypeKey
product_idINTPK
product_codeTEXT
product_nameTEXT
categoryTEXT
subcategoryTEXT
default_aprREAL
default_apyREAL
monthly_feeREAL
nsf_feeREAL
od_feeREAL

Hints (3)

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

Hint 1

Customer state and account product type live in different tables. You'll need to bring them together — three-table join through retail_accounts and retail_products to get from customer demographics to product subcategory.

Hint 2

Filter: `retail_products.subcategory IN ('Checking', 'Savings')` AND `retail_accounts.status = 'Open'`.

Hint 3

GROUP BY state, COUNT DISTINCT on customer_id (because a customer with both a Checking AND a Savings would otherwise be counted twice), and ORDER BY the count descending.