Credit Risk & Banking Path · Mission 6 of 30Easy

Reversals and chargebacks — clean the spend total

Filter noise rows out of a SUM using WHERE — the data-quality-before-reporting pattern

Back to Credit Risk & Banking

The Brief

Diane HoltzControllercontroller

Ops team is reporting a total spend number that doesn't reconcile to the GL — by a lot. I suspect they're summing raw `banking_transactions.amount` without excluding reversals and chargebacks. Please give me the clean total: SUM of `amount` where `is_reversal = 0` AND `is_chargeback = 0`. Call the column `total_clean_spend`. Single number.

You'll practice

WHERESUMData quality

Tables & columns available

banking_transactionsfact8 columns
ColumnTypeKey
txn_idINTPK
account_idINTFK → banking_accounts
posted_dateTEXT
amountREAL
merchant_categoryTEXT
channelTEXT
is_reversalINT
is_chargebackINT

Hints (3)

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

Hint 1

Reversal rows carry the SAME positive amount as the original transaction (absolute-value convention in this source system). If you sum them in, you double-count.

Hint 2

Chargebacks are flagged on the original transaction itself — not as a separate line. Exclude them the same way.

Hint 3

SUM the amount with both flags filtered to 0 in the WHERE clause, alias the column total_clean_spend. Worth running the unfiltered SUM separately to see how big the gap is.