sql-queries

Installation
SKILL.md

SQL queries

SQL fails quietly. A query with a wrong join returns rows — just the wrong ones, and nothing errors. The number looks plausible, someone puts it in a report, and it is wrong for months.

Verify the row count before trusting the aggregate. That single habit catches most SQL bugs.

1. Say what one row of the result means

Before writing, state the grain: "one row per order" or "one row per customer per month". Almost every SQL bug is a grain the author did not intend.

Then check it. If you expect one row per order and get 1,400 rows for 1,200 orders, a join fanned out, and any SUM over that result is now inflated.

SELECT COUNT(*) FROM ...;                       -- vs. what you expect
SELECT order_id, COUNT(*) FROM ... GROUP BY 1 HAVING COUNT(*) > 1;
Installs
3
GitHub Stars
1
First Seen
9 days ago
sql-queries — arjunprabhulal/agent-skills