← ClaudeAtlas

sql-correctness-reviewlisted

Audits a SQL query's logic for wrong-results bugs — duplicate rows, join fanout, wrong join types, NULL handling traps, and CASE branch issues — with evidence queries that prove or clear each suspicion. Use when the user says "numbers look wrong", "double counting", "rows are duplicated", "this join is exploding", "check my query logic", or when totals don't reconcile.
vermapragya/analytics-skill · ★ 0 · Code & Development · score 72
Install: claude install-skill vermapragya/analytics-skill
# SQL Correctness Review ## When to use this skill Use when a query might return **wrong results** — regardless of how fast it runs. Triggers: - "These numbers look too high/low" - "Revenue is double-counting" - "Why do I have duplicate rows?" - "This join is exploding" - "Check the logic of this query" - Two reports disagree on the same metric Routing: performance/anti-patterns → `sql-query-review`. Bad data *in the table* (not the query) → `data-quality-audit`. The first job here is deciding which of the two it is. ## Required inputs | Input | Why it matters | |---|---| | Query text | The suspect | | Expected output grain | "One row per X" — every check is relative to this | | Key relationships | Which joins are 1:1 vs 1:N (or what you *believe* they are) | | A reconciliation anchor | A number you trust (row count, total from a source system) to diff against | | Access to run SQL | Evidence queries are the core of this skill | ## The five bug classes | # | Class | Symptom | Canonical cause | |---|---|---|---| | 1 | Duplicates | Row count too high; metrics inflated | Source table grain misunderstood; missing dedup | | 2 | Join fanout | Totals inflate after a join | Joining on a partial key (1:N or N:M treated as 1:1) | | 3 | Wrong join type | Rows silently disappear | INNER where LEFT intended; WHERE on a LEFT join's right table | | 4 | NULL handling | Rows vanish or comparisons silently fail | NOT IN + NULL; `col != 'x'` dropping NULLs; NULL join keys | | 5 | CASE i