Deduplicate Bank Transactions Imported Through Two Connections

Last updated: November 29, 2026

Quick Overview

A business connected the same bank account to QuickBooks twice, so many transactions were imported twice with different ids. Write SQL that removes the duplicates while keeping genuine repeated purchases, such as two identical coffee charges on the same day.

Intuit
Data Manipulation (SQL/Python)
Data Engineer
Intuit
November 29, 2026
Data Engineer
Onsite
Data Manipulation (SQL/Python)
Medium

0

0

0 solved


A business connected the same bank account to QuickBooks twice, so many transactions were imported twice with different ids. Write SQL that removes the duplicates while keeping genuine repeated purchases, such as two identical coffee charges on the same day.

Duplicate bank feed rows are a real QuickBooks support pain, and Intuit data engineers are expected to dedupe without destroying legitimate repeats. The interviewer is checking whether you see that a plain DISTINCT over business columns deletes real transactions, and whether you pair occurrences across sources instead.

What the Interviewer Expects
  • Explain why DISTINCT on (account, date, amount, description) is wrong
  • Normalize description text before comparing
  • Number occurrences within each source with ROW_NUMBER and pair the nth with the nth
  • Keep the row from the preferred or earliest connection
  • Validate counts before deleting
Key Topics to Cover
deduplication
ROW_NUMBER
joins
data quality
idempotent cleanup
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • The two feeds post the same charge one day apart. How would you match them?
  • How would you prevent the duplication at ingestion time instead of cleaning it up later?
  • Some duplicates are already matched to invoices in the ledger. What do you do with those?
  • How would you make this delete safe to rerun?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

feed_txns(txn_id, company_id, bank_account_id, connection_id, posted_date, amount_cents, description, imported_at). Both connections point to the same real bank account. If a business buys two 4.50 ...

Approach

Build a match key: (company_id, bank_account_id, posted_date, amount_cents, normalized description). Within each key and each connection, number rows with ROW_NUMBER() ordered by imported_at. Th...


Submit Your Answer
Markdown supported

Related Questions