Detect Split Invoices Kept Just Under an Approval Threshold

Last updated: November 29, 2026

Quick Overview

Invoices above 10,000 need a second approver. Write SQL that finds groups of two or more invoices from the same vendor, approved by the same person within any 3 day window, that are each under the threshold but together reach or exceed it.

Deloitte
Data Manipulation (SQL/Python)
Data Scientist
Deloitte
November 29, 2026
Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
Hard

0

0

0 solved


Invoices above 10,000 need a second approver. Write SQL that finds groups of two or more invoices from the same vendor, approved by the same person within any 3 day window, that are each under the threshold but together reach or exceed it.

Threshold avoidance through invoice splitting is a standard control test in internal audit and forensic engagements, and Deloitte analytics staff write this kind of query directly against a client's AP extract. The interviewer looks for a correct rolling window, sensible deduplication of overlapping windows, and awareness of what the control is actually trying to catch.

What the Interviewer Expects
  • Filters to under-threshold invoices before windowing
  • Defines the window per anchor invoice with a self join or range window
  • Groups by vendor and approver, the pair the control cares about
  • Deals with overlapping windows that report the same scheme several times
  • Discusses tuning: threshold, window length, and minimum count
Key Topics to Cover
self join
rolling window
threshold avoidance
internal controls
GROUP BY
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
  • How would you collapse overlapping windows into one case per scheme?
  • The vendor splits across two related vendor ids. How would you catch that?
  • How would you express the window with a RANGE frame instead of a self join?
  • How do you size the result so auditors are not handed 4,000 false positives?
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

invoices(invoice_id, vendor_id, approver_id, amount, invoice_date), one row per approved invoice, amounts in a single currency. Threshold 10,000, window 3 days inclusive measured from the earliest i...

Approach

Keep only invoices below the threshold, since an invoice already above it went to a second approver anyway. Treat every invoice as a window anchor: self join to all same-vendor, same-approver invoices...


Submit Your Answer
Markdown supported

Related Questions