Retail Banking Operations Path · Mission 12 of 30Medium

Rate-tier balance distribution

Histogram bucketing with CASE WHEN

The Brief

Jordan KimTreasurerretail-ops

Product team is reviewing the MMA tiering. I want a balance histogram for our open MMA accounts using these breaks: under $10K, $10K to under $25K, $25K to under $50K, $50K and up. From `retail_accounts` joined to `retail_products`, filter `subcategory = 'MMA'` and `status = 'Open'`. Two columns: `tier` (the bucket label, prefixed `1_` / `2_` / `3_` / `4_` so it sorts cleanly) and `n_accounts`. Sort by tier ascending. Tiers with zero accounts can be omitted — I just want what's actually in the book.

You'll practice

HistogramCASE bucketing

Tables & columns available

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

Three CASE branches plus an ELSE for the top bucket. Label each tier with a leading digit (`'1_under_10k'`, `'2_10k_to_25k'`, ...) so ORDER BY puts them in numeric order rather than alphabetical.

Hint 2

Filter the join: `subcategory = 'MMA'` AND `status = 'Open'`. Anything else (other deposit products, closed accounts) shouldn't be in the rollup.

Hint 3

GROUP BY the tier expression, COUNT(*) for the count, ORDER BY the tier ascending. Tiers with zero accounts simply don't appear — that's fine for this mission.