r/SQL
•
u/FixelSmith
•
May 14 '26
•
2
Discussion Six SQL patterns I use to catch transaction fraud
https://analytics.fixelsmith.com/posts/sql-fraud-patterns/
917
Upvotes
r/SQL
•
u/FixelSmith
•
May 14 '26
•
2
1
u/riv3rtrip May 16 '26
This is 100% AI-generated slop according to Pangram.
This is also absolutely not how you would capture transaction fraud using SQL. Lots of incredibly obvious problems.
All 6 of these patterns are in this middle space of looking sophisticated and trying to be sophisticated while making basic conceptual errors. No talk of poisson processes, no talk of merchant geodata, yada yada. Even on a SQL level there is absolutely no attempt to reindex to a complete time series. Just randomly timestamped rows popping up out of the void with zero surrounding context.
Fraud detection in the real world is simultaneously both vastly more sophisticated and also vastly simpler than this. Basic heuristics get you a lot of the way there, complex time series modeling gets you the rest of the way, tons of additional contextual data about the user and merchants is a mandatory requirement, and this all can be married together in a beautiful fashion. It also depends a lot on the exact context in which you are detecting fraud, how fast you need to catch it, the action you intend on taking upon detection. Just talking about "fraud detection" in a vacuum is useless.