Fifteen SQL mistakes that don't throw an error. The query runs, returns something that looks reasonable, and it's wrong.
Each one comes with the query that has the trap, the fix, why it happens, and a minimal dataset. verify.py runs all of them in DuckDB and checks that the broken query and the fixed one really give different results, in the way the page says. Nothing here is just asserted.
In English and in Spanish.
pip install duckdb
python verify.py # all of them
python verify.py fanout # just oneThe SQL is DuckDB. Almost all of it is plain standard SQL; where an engine behaves differently (for example, DuckDB's / never does integer division) the page says so.
They are the traps hidden in the case files of Caso Abierto, a detective game where you solve each case by writing SQL and have to hand in the query that proves your accusation. The first case plays free in the browser.
Quince errores de SQL que no dan error. La consulta corre, devuelve algo razonable y está mal.
Cada una trae la consulta con la trampa, la corrección, por qué pasa y un dataset mínimo. verify.py las ejecuta todas en DuckDB y comprueba que la consulta rota y la corregida dan resultados distintos, en el sentido que explica cada página.
Salen de los casos de Caso Abierto, un juego de detectives que se resuelve escribiendo SQL. El primer caso se juega gratis en el navegador.
Text: CC BY 4.0. Code (verify.py): MIT.