Finance Path · Mission 16 of 25Hard

Duplicate payment detection

GROUP BY composite key + HAVING for anomaly detection

Back to Finance

The Brief

Daniel OkaforControlleraccounting

AP ran a duplicate payment scan — find any (vendor_id, amount, txn_date) triples that appear more than once. Posted only. Columns: `vendor_id`, `txn_date`, `amount`, `occurrences`. Usually zero, but we've had scares.

You'll practice

Self-joinDate windowGROUP BY HAVING

Tables available

fact_transactions

Hints (3)

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

Hint 1

GROUP BY (vendor_id, txn_date, amount) on fact_transactions where posted = 1.

Hint 2

HAVING COUNT(*) > 1.

Hint 3

Alias COUNT(*) as `occurrences`.