← ClaudeAtlas

data-analytics-sql-reviewlisted

Reviews analytical SQL for correctness and cost: the join fan-out and row-loss traps, filters that silently change join semantics, window and grain errors, null and timezone handling, then scan volume, partition pruning, and predicate placement. Use when a query is about to feed a report or model, when results look wrong or duplicated, when a query is expensive or slow, or when reviewing someone else's analytical SQL. Trigger on 'review this query', 'why are my rows duplicated', 'this query is expensive', 'check my SQL', 'the join is wrong', 'why is this so slow'. Not for verifying a finished report's outputs against an independent source — that is data-analytics-report-qa; not for deciding what the metric should mean, which is data-analytics-metric-definition.
alihusains/enterprise-skills · ★ 0 · AI & Automation · score 73
Install: claude install-skill alihusains/enterprise-skills
# Analytical SQL review ## Purpose Analytical SQL fails quietly. A join fans out and the revenue total doubles; an inner join drops the rows with no matching dimension and the count is 4% low; a filter in the WHERE clause turns a left join into an inner one. None of these raise an error, and all of them produce a number someone will act on. This skill is the ordered checklist for those failure classes, plus the cost review that stops a correct query from being unaffordable. ## Prerequisites - **Inputs:** the query; the grain each source table is at (one row per what?); expected row counts or an order of magnitude for the result; the metric definition it implements. - **Access:** ability to run the query's plan and row counts against a representative dataset. Reviewing SQL by reading alone catches syntax and obvious logic errors, but not fan-out — that needs counts. If nobody can state the grain of each source table, establish that first. Almost every fan-out and row-loss bug is a grain misunderstanding, and no amount of reading the SQL surfaces it. ## Procedure ### Pass 1 — Correctness 1. **State the grain of every source and the intended grain of the output.** Write it down as a sentence per table: "one row per order line", "one row per customer per day". Then check every join: joining a one-row-per-customer table to a one-row-per-order table produces one row per order — if an aggregate downstream sums a customer-level column, it is now multiplied