<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/sql-interview-problem-the-suspicious-split-2-challenges-to-solve-yourself--5yazwipqg" -->

---
title: SQL Interview Problem: The Suspicious Split (+ 2...
description: A walkthrough of a SQL interview problem called 'The Suspicious Split,' where employees may be splitting large expenses into two smaller transactions to avoid...
canonical: https://daily.dev/posts/sql-interview-problem-the-suspicious-split-2-challenges-to-solve-yourself--5yazwipqg
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: SQL Interview Problem: The Suspicious Split (+ 2 Challenges to Solve Yourself) | daily.dev
og:description: A walkthrough of a SQL interview problem called 'The Suspicious Split,' where employees may be splitting large expenses into two smaller transactions to avoid...
og:url: https://daily.dev/posts/sql-interview-problem-the-suspicious-split-2-challenges-to-solve-yourself--5yazwipqg
og:image: https://api.daily.dev/og/posts/5YAzWIPqG.png
og:image:alt: SQL Interview Problem: The Suspicious Split (+ 2 Challenges to Solve Yourself)
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# SQL Interview Problem: The Suspicious Split (+ 2 Challenges to Solve Yourself)

**[techTFQ](https://daily.dev/sources/techtfq)** · 18 min read · 0 upvotes · 0 comments

## Summary

A walkthrough of a SQL interview problem called 'The Suspicious Split,' where employees may be splitting large expenses into two smaller transactions to avoid manager approval thresholds. The solution uses a self join on an expense transactions table, joining on employee ID with a transaction ID inequality to avoid duplicate pairs, then filtering on individual amounts under $1,000, combined amount over $1,000, and a date difference of 3 days or less using ABS(). Two additional premium problems (Peak Hour and Bundle Completionist) are left as challenges, both free for one week on SQL Nest before requiring a premium subscription.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=wMB04i-IihI>

## Questions this post answers

### How do you write a SQL query to detect employees splitting a large expense into two smaller transactions to avoid approval thresholds?

Use a self join on the transactions table, joining on employee id with a condition like t1.transaction_id < t2.transaction_id to avoid duplicate pairs. Add filters so both amounts are under 1000, their sum is 1000 or more, and abs(t1.date - t2.date) is less than or equal to 3 days, then order by combined amount descending.

_daily.dev surfaces SQL self-join techniques like this for developers building fraud or anomaly detection queries._

### Why use a self join instead of LEAD or LAG window functions to compare transactions within the same group in SQL?

A self join lets every transaction row be compared against every other transaction row for the same employee, which is necessary here because a qualifying pair does not have to be adjacent in the data or the next chronological transaction. LEAD and LAG only compare a row to its immediate neighbor in an ordered sequence, so they would miss non-adjacent matching pairs.

_developers weighing self joins versus window functions can find comparisons like this through daily.dev._

## Similar posts on daily.dev

- [10 Simple Steps to Solve SQL Problems \[2026\]](https://daily.dev/posts/10-simple-steps-to-solve-sql-problems-2026--uicxpyy02) · Planet MySQL · 0 upvotes · 0 comments
- [Six SQL patterns I use to catch transaction fraud](https://daily.dev/posts/six-sql-patterns-i-use-to-catch-transaction-fraud-0vozg6gea) · Hacker News · 0 upvotes · 0 comments
- [Project 1: Customer Intelligence Layer — Findings](https://daily.dev/posts/project-1-customer-intelligence-layer-findings-vtppzsyxj) · Medium · 0 upvotes · 0 comments
- [NOLOCK Double Counting: One Employee, Two Lunches](https://daily.dev/posts/nolock-double-counting-one-employee-two-lunches-luwupnpiz) · SQL Authority · 0 upvotes · 0 comments

---

Tags: [#sql](https://daily.dev/tags/sql), [#interview-questions](https://daily.dev/tags/interview-questions)

[View this post on daily.dev](https://daily.dev/posts/sql-interview-problem-the-suspicious-split-2-challenges-to-solve-yourself--5yazwipqg)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"SQL Interview Problem: The Suspicious Split (+ 2 Challenges to Solve Yourself)","url":"https://daily.dev/posts/sql-interview-problem-the-suspicious-split-2-challenges-to-solve-yourself--5yazwipqg","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/sql-interview-problem-the-suspicious-split-2-challenges-to-solve-yourself--5yazwipqg"},"datePublished":"2026-08-14T12:39:35.118Z","dateModified":"2026-09-14T06:29:47.259Z","description":"A walkthrough of a SQL interview problem called 'The Suspicious Split,' where employees may be splitting large expenses into two smaller transactions to avoid...","image":"https://i.ytimg.com/vi/wMB04i-IihI/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/wMB04i-IihI/sddefault.jpg","isAccessibleForFree":true,"articleSection":"techTFQ","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"techTFQ","logo":"https://media.daily.dev/image/upload/s--dgjhXj89--/f_auto,q_auto/v1780213385/logos/techtfq?_a=BAMAMiWQ0","url":"https://daily.dev/sources/techtfq"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/sql-interview-problem-the-suspicious-split-2-challenges-to-solve-yourself--5yazwipqg","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"sql,interview-questions","timeRequired":"PT18M","video":{"@type":"VideoObject","name":"SQL Interview Problem: The Suspicious Split (+ 2 Challenges to Solve Yourself)","description":"A walkthrough of a SQL interview problem called 'The Suspicious Split,' where employees may be splitting large expenses into two smaller transactions to avoid...","thumbnailUrl":"https://i.ytimg.com/vi/wMB04i-IihI/sddefault.jpg","uploadDate":"2026-08-14T12:39:35.118Z","duration":"PT18M","url":"https://api.daily.dev/r/5YAzWIPqG","embedUrl":"https://www.youtube.com/embed/wMB04i-IihI"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"techTFQ","item":"https://daily.dev/sources/techtfq"},{"@type":"ListItem","position":3,"name":"SQL Interview Problem: The Suspicious Split (+ 2 Challenges to Solve Yourself)"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/sql-interview-problem-the-suspicious-split-2-challenges-to-solve-yourself--5yazwipqg#faq","mainEntity":[{"@type":"Question","name":"How do you write a SQL query to detect employees splitting a large expense into two smaller transactions to avoid approval thresholds?","acceptedAnswer":{"@type":"Answer","text":"Use a self join on the transactions table, joining on employee id with a condition like t1.transaction_id < t2.transaction_id to avoid duplicate pairs. Add filters so both amounts are under 1000, their sum is 1000 or more, and abs(t1.date - t2.date) is less than or equal to 3 days, then order by combined amount descending. daily.dev surfaces SQL self-join techniques like this for developers building fraud or anomaly detection queries."}},{"@type":"Question","name":"Why use a self join instead of LEAD or LAG window functions to compare transactions within the same group in SQL?","acceptedAnswer":{"@type":"Answer","text":"A self join lets every transaction row be compared against every other transaction row for the same employee, which is necessary here because a qualifying pair does not have to be adjacent in the data or the next chronological transaction. LEAD and LAG only compare a row to its immediate neighbor in an ordered sequence, so they would miss non-adjacent matching pairs. developers weighing self joins versus window functions can find comparisons like this through daily.dev."}}]}
```

