Posted by Colin, Nov. 29, 2025, 4:04 p.m.
131: Model solution is wrong...includes deletion from July when question refers exclusively to August churn.
You can run the query below to see that it's pulling ID 8004's deletion on 7/30 into the solution during the join in the `potential_deleted_both_account` subquery.
This is because one of 8004's deletion actions meet the '2021-08-01' AND '2021-08-31' requirement...but the join, which only considers month and not id, then inaccurately tags 8004's 7/30 deletion as within scope. Which then results in an answer of 5 when it should actually only be 4.
WITH deleted_single_account AS
(
SELECT id, account_type
FROM affirm_account
WHERE action='created'
AND id IN (
SELECT DISTINCT id
FROM affirm_account
WHERE action='deleted'
AND date BETWEEN '2021-08-01' AND '2021-08-31'
)
AND account_type IN ('checking', 'saving')
),
potential_deleted_both_account AS (
SELECT *
FROM affirm_account
WHERE action='created'
AND id IN (
SELECT DISTINCT id
FROM affirm_account
WHERE action='deleted'
AND date BETWEEN '2021-08-01' AND '2021-08-31'
)
AND account_type = 'both'
),
deleted_both_account AS (
SELECT *
FROM affirm_account
WHERE id IN (
SELECT id
FROM potential_deleted_both_account
)
AND action='deleted'
)
SELECT *
FROM deleted_both_account;
Additionally, the question is contradictory. It states:
“A user can delete a saving account if he created a ‘both’ account and remain active.”
But it also says:
“For a ‘both’ account to churn, a user must delete both checking AND saving.”
If a `both` account only churns after both deletions happen, then deleting only saving leaves the account active. This is stated in the prompt. But if both accounts are required to be deleted, then the account must also remain active when deleting only checking. Unclear why the prompt only mentions savings when the logic applies equally to both account types.