Simple Anomaly Detection Using Plain SQL

Many developers think that having a critical bug in their code is the worst thing that can happen. Well, there is something much worse than that: Having a critical bug in your code and not knowing about it!

To make sure I get notified about critical bugs as soon as possible, I started looking for ways to find anomalies in my data. I quickly found that information about these subjects tend to get very complicated, and involve a lot of ad-hoc tools and dependencies.

I’m not a statistician and not a data scientist, I’m just a developer. Before I introduce dependencies into my system I make sure I really can’t do without them. So, using some high school level statistics and a fair knowledge of SQL, I implemented a simple anomaly detection system that works.

Can you spot the anomaly? (Photo by Ricardo Gomez Angel)