Consumer Lending Analyst Path · Mission 12 of 30Medium

HMDA denial-reason rollup

Window function for total-of-group share + NULL filtering on a HMDA-coded column

The Brief

Rashida OkonkwoFair Lending Compliance Officerconsumer-lending

Pre-LAR denial review. Pull the distribution of `denial_reason_1` codes across denied applications (`action_taken = 3`). Skip rows where `denial_reason_1 IS NULL` — those would fail FFIEC validation anyway and don't belong on this slide. Three columns: `denial_reason_1` (integer code), `denied_count`, `pct_of_denials` (4 decimals, share of the denial population not the full app population). Sort by count descending, then code ascending.

You'll practice

Conditional aggregationNULL handling

Tables & columns available

lending_applicationsfact18 columns
ColumnTypeKey
app_idINTPK
customer_idINTFK → retail_customers
product_idINTFK → retail_products
application_dateTEXT
requested_amountREAL
requested_termINT
loan_purposeTEXT
action_takenINT
denial_reason_1INT
aus_recommendationTEXT
rate_spreadREAL
lien_statusINT
occupancyINT
ethnicityINT
raceINT
sexINT
age_bucketTEXT
property_tractTEXTFK → lending_geography

Hints (3)

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

Hint 1

Two filters compose: action_taken restricted to denied applications, AND `denial_reason_1 IS NOT NULL`. The latter catches the handful of incomplete records that would fail FFIEC validation anyway and don't belong on the slide.

Hint 2

For "share of group total in the same SELECT," reach for an aggregate window function — the family that lets you compute a grand total alongside each grouped row without a self-join or a separate CTE. Look up `SUM(...) OVER ()` and how it composes with COUNT.

Hint 3

Three projected columns; two-key sort (count desc, code asc). Round the share to 4 decimals so the deck formats cleanly.