AnalystPath

At-Risk Credit Card Customers

SQLMediumMid levelCapital One~15 min

Problem

**[Asked at Capital One]**

Capital One flags customers as **at-risk** if they meet both conditions:
1. They had **at least one transaction between 31 and 90 days ago**
(relative to the latest date in the table — `'2023-03-31'`)
2. They had **no transactions in the last 30 days**
(i.e., no transactions after `'2023-03-01'`)

Find all at-risk customer IDs. Return `customer_id`, ordered ascending.

Tables

Example rows — the live problem includes the full dataset.

transactions
txn_idcustomer_idamounttxn_date

Expected output

Your answer should return 3 rows with the columns customer_id.

Starter code (SQL)

SELECT *
FROM transactions;

Solve this SQL question free

Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.

Solution & explanation

Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.

Sign up free to unlock

Related SQL questions