An AI assistant will write you a query in ten seconds, the query will run, and the number that comes back will look completely reasonable. This page gives you the five checks that tell you whether that number is right. They take about two minutes, they need no tools beyond the database you already have, and they catch the four mistakes AI-written SQL actually makes.

The order matters. The checks are arranged cheapest first, so the first one costs a single row count and the last one costs a short conversation. Most wrong queries fall to the first two.

The short version. A query that runs has only passed a grammar check. The number is right when the rows, the filters and the denominator match the question you asked.

The database only takes a query as far as the first gate.

Why a query that runs can still be wrong