Credit Risk & Banking Path · Mission 5 of 30Starter

Customer vs account — know the grain

COUNT vs COUNT DISTINCT to reason about table grain

Back to Credit Risk & Banking

The Brief

David OkonkwoHead of Portfolio Analyticsportfolio-analytics

The CFO asked why our 'customer count' in the board deck is smaller than our 'account count', and my team gave three different answers. Please end this. One query against `banking_accounts`: total account rows vs distinct customer_ids. Call them `total_accounts` and `unique_customers`. I want this as evidence for the next Teams thread.

You'll practice

COUNT DISTINCTGrain reasoning

Tables & columns available

banking_accountsdim8 columns
ColumnTypeKey
account_idINTPK
customer_idINTFK → banking_customers
product_typeTEXT
open_dateTEXT
close_dateTEXT
credit_limitREAL
current_ficoINT
statusTEXT

Hints (3)

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

Hint 1

You need two different counts from the same table — total rows, and unique customers. Think about what the difference between those two numbers tells you about how many accounts each customer holds on average.

Hint 2

Two aggregates in a single SELECT — one COUNT(*) for total rows and one COUNT(DISTINCT customer_id) for unique customers — both aliased to the names the briefing called out.

Hint 3

Single row, two columns. The ratio is the average number of accounts per customer — useful context to drop into your reply.