Skip to content
Log in

SQL Review for Correctness

Reviews a query for the silent wrongness that produces plausible numbers — fan-out joins, null semantics and filters applied after the outer join.

0

Share this prompt

Free — no card needed

Create a free account

to open SQL Review for Correctness — and the other 364 prompts across 21 categories.

We store your email address to send these. We never sell it or pass it to advertisers. Withdraw at any time. Privacy Policy.

Already have an account?

CategoryData AnalysisForAnalysts, DevelopersTested onClaudeChatGPTGemini

Running it, start to finish

  1. Paste the query with the schema, grain and cardinality.
  2. Fix the fan-out findings first — they distort everything downstream.
  3. Run the section 8 checks before the number leaves your screen.

What you get back

The output this produces, every time.

  • Traces grain through every join to catch the fan-out that silently inflates a metric.
  • Checks whether a filter turned your outer join into an inner one, which is common and invisible.
  • Supplies runnable sanity-check queries to verify the result independently.

Getting better results

Where this usually goes wrong, and how to avoid it.

  • Give it real cardinality. Section 1 is the highest-value check and it needs to know which relationships are one-to-many.
  • Check every DISTINCT. Section 4 frequently finds a DISTINCT hiding a join problem, which produces a wrong number that looks entirely reasonable.
  • Run the sanity checks. before presenting anything. Reconciling against a known total catches most of what review misses.

More Data Analysis prompts

All Data Analysis

Written for The AI University. Every prompt in this library is original work — authored, tested and revised here, not collected from elsewhere. 365 of them, free with an account.