Consumer Lending Analyst Path · Mission 18 of 30Hard

Refi candidate cohort

Multi-CTE with NOT EXISTS for negative-existence filter on payment history + CROSS JOIN to a scalar benchmark

The Brief

Jennifer WhitmanMortgage Sales Directorconsumer-lending

Refi outreach list for the LO desk. Surface every current-status MTG-30Y origination priced at least 50bp above today's MTG-30Y benchmark, with NO late or missed payments in the last 6 months. Six columns: `origination_id`, `customer_name`, `funded_amount`, `interest_rate`, `benchmark_rate` (the MTG-30Y default APR), `premium_bp` (integer, basis points above bench). Sort by premium_bp DESC, origination_id ASC.

You'll practice

EXISTSMulti-conditionRecent-payment filter

Tables & columns available

lending_originationsfact17 columns
ColumnTypeKey
origination_idINTPK
app_idINTFK → lending_applications
account_idINTFK → retail_accounts
funded_dateTEXT
funded_amountREAL
term_monthsINT
interest_rateREAL
rate_typeTEXT
arm_reset_dateTEXT
fico_at_origINT
dti_at_origREAL
ltv_at_origREAL
property_valueREAL
lo_nameTEXT
channelTEXT
current_statusTEXT
closed_dateTEXT
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
lending_paymentsfact10 columns
ColumnTypeKey
payment_idINTPK
origination_idINTFK → lending_originations
due_dateTEXT
paid_dateTEXT
scheduled_amountREAL
principal_paidREAL
interest_paidREAL
escrow_paidREAL
days_lateINT
statusTEXT
retail_productsdim6 columns
ColumnTypeKey
product_idINTPK
product_codeTEXT
product_nameTEXT
categoryTEXT
subcategoryTEXT
default_aprREAL

Hints (3)

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

Hint 1

Three composable pieces: a benchmark scalar (today's 30-year mortgage default APR), a target population (current-status mortgages priced above the benchmark by enough to matter), and a clean-payment-history gate. CTE-per-piece keeps each readable.

Hint 2

For the benchmark, return a single-row CTE pulling default_apr off `retail_products` for the right product. CROSS JOIN it to the targets so each row carries the benchmark without a correlated subquery in the WHERE.

Hint 3

For "no late or missed payments in the last 6 months," reach for `NOT EXISTS` against the payments table — correlate the inner query on origination_id, the recent-window date, and the bad-status set. NOT EXISTS reads cleaner than a LEFT JOIN + COUNT = 0 once multiple criteria compose. Premium_bp is the same bp formula from M14.