Audit intermediate Works with: Any AI

SQL Query Review Checklist for Correctness, Not Just Speed

Table output

Review a query for logic errors.

The Open buttons send the prompt text as currently shown below to that site only when you click. Fill in the placeholders first.

[VERIFY] is an editorial flag, not a blank to fill. Wherever the prompt shows [VERIFY], check that item against a reliable source before you use it.

Rate this prompt

Loading ratingsโ€ฆ

Review this SQL query for correctness. Query: [QUERY]. Intended result in words: [INTENDED_RESULT]. Table notes: [TABLE_NOTES]. Database: [DATABASE].

Check join types and conditions, duplicate-causing joins, filters in WHERE versus ON and their effect on outer joins, NULL handling in comparisons and aggregates, date boundaries, integer division, grouping columns, DISTINCT hiding problems, and ordering assumptions. Do not change business meaning without asking. Provide a table of five worked examples with invented data showing wrong results: a left join with a filter in WHERE that turns it into an inner join; a join to a one-to-many table that doubles an amount (an order of 100 with 2 lines becomes 200); NOT IN with NULLs returning no rows; an inclusive end date that excludes the last day when the column has a time; and an average of averages. For each give the pattern, the wrong result, the right result and the fix, then Line, Issue, Example and Fix for my query.

Test procedure: compute totals two different ways and compare, and test with a tiny dataset where the answer is known. Provide a checklist for pull requests that include SQL, and flag version-dependent claims [VERIFY].

Fill in before use

Optional: type your details and the prompt above updates. Nothing is saved or sent.

Replace each bracketed placeholder with your own details, then paste into Any AI or another assistant.

Related prompts