Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Quick reference for common SQL patterns, CTEs, window functions, and indexing strategies. Triggers on: sql patterns, cte example, window functions, sql join, index strategy, pagination sql.
.claude/skills/aiskillstore-sql-patterns/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-19 | ✗→✓ | ▲ Improved | 93% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 119% | 0% |
| case-01 | ✓→✓ | = Same ✓ | 6% | 0% |
| case-20 | ✓→✓ | = Same ✓ | 7% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 59% | 0% |
Quick reference for common SQL patterns.
sqlWITH active_users AS ( SELECT id, name, email FROM users WHERE status = 'active' ) SELECT * FROM active_users WHERE created_at > '2024-01-01';
sqlWITH active_users AS ( SELECT id, name FROM users WHERE status = 'active' ), user_orders AS ( SELECT user_id, COUNT(*) as order_count FROM orders GROUP BY user_id ) SELECT u.name, COALESCE(o.order_count, 0) as orders FROM active_users u LEFT JOIN user_orders o ON u.id = o.user_id;
| Function | Use | |----------|-----| | ROW_NUMBER() | Unique sequential numbering | | RANK() | Rank with gaps (1, 2, 2, 4) | | DENSE_RANK() | Rank without gaps (1, 2, 2, 3) | | LAG(col, n) | Previous row value | | LEAD(col, n) | Next row value | | SUM() OVER | Running total | | AVG() OVER | Moving average |
sqlSELECT date, revenue, LAG(revenue, 1) OVER (ORDER BY date) as prev_day, SUM(revenue) OVER (ORDER BY date) as running_total FROM daily_sales;
| Type | Returns | |------|---------| | INNER JOIN | Only matching rows | | LEFT JOIN | All left + matching right | | RIGHT JOIN | All right + matching left | | FULL JOIN | All rows, NULL where no match |
sql-- OFFSET/LIMIT (simple, slow for large offsets) SELECT * FROM products ORDER BY id LIMIT 20 OFFSET 40; -- Keyset (fast, scalable) SELECT * FROM products WHERE id > 42 ORDER BY id LIMIT 20;
| Index Type | Best For | |------------|----------| | B-tree | Range queries, ORDER BY | | Hash | Exact equality only | | GIN | Arrays, JSONB, full-text | | Covering | Avoid table lookup |
| Mistake | Fix | |---------|-----| | SELECT * | List columns explicitly | | WHERE YEAR(date) = 2024 | WHERE date >= '2024-01-01' | | NOT IN with NULLs | Use NOT EXISTS | | N+1 queries | Use JOIN or batch |
For detailed patterns, load:
./references/window-functions.md - Complete window function patterns./references/indexing-strategies.md - Index types, covering indexes, optimization| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-02 | pass→pass | 3,411 | 3,094 | -9% | 1 | 1 | 0% | 575 | 1,258 | +119% | 0 | 0 | — |
case-01 | pass→pass | 6,937 | 3,441 | -50% | 1 | 1 | 0% | 1,285 | 1,361 | +6% | 0 | 0 | — |
case-20 | pass→pass | 9,311 | 6,096 | -35% | 1 | 1 | 0% | 1,565 | 1,676 | +7% | 0 | 0 | — |
case-03 | pass→pass | 4,642 | 4,249 | -8% | 1 | 1 | 0% | 912 | 1,447 | +59% | 0 | 0 | — |
case-04 | pass→pass | 3,369 | 2,730 | -19% | 1 | 1 | 0% | 574 | 1,173 | +104% | 0 | 0 | — |
case-05 | pass→pass | 4,714 | 3,737 | -21% | 1 | 1 | 0% | 850 | 1,280 | +51% | 0 | 0 | — |
case-06 | pass→pass | 9,237 | 5,893 | -36% | 1 | 1 | 0% | 1,639 | 1,783 | +9% | 0 | 0 | — |
case-15 | pass→pass | 3,411 | 3,181 | -7% | 1 | 1 | 0% | 615 | 1,224 | +99% | 0 | 0 | — |
case-07 | pass→pass | 11,686 | 6,024 | -48% | 1 | 1 | 0% | 2,018 | 1,820 | -10% | 0 | 0 | — |
case-08 | pass→pass | 8,767 | 6,006 | -31% | 1 | 1 | 0% | 1,376 | 1,681 | +22% | 0 | 0 | — |
case-09 | pass→pass | 10,143 | 7,785 | -23% | 1 | 1 | 0% | 1,704 | 2,063 | +21% | 0 | 0 | — |
case-10 | pass→pass | 11,372 | 8,320 | -27% | 1 | 1 | 0% | 1,931 | 2,074 | +7% | 0 | 0 | — |
case-11 | pass→pass | 5,722 | 3,857 | -33% | 1 | 1 | 0% | 1,071 | 1,385 | +29% | 0 | 0 | — |
case-12 | pass→pass | 9,918 | 6,888 | -31% | 1 | 1 | 0% | 1,799 | 1,956 | +9% | 0 | 0 | — |
case-13 | pass→pass | 7,637 | 5,742 | -25% | 1 | 1 | 0% | 1,266 | 1,665 | +32% | 0 | 0 | — |
case-14 | pass→pass | 3,446 | 3,355 | -3% | 1 | 1 | 0% | 600 | 1,277 | +113% | 0 | 0 | — |
case-16 | pass→pass | 4,423 | 3,147 | -29% | 1 | 1 | 0% | 813 | 1,243 | +53% | 0 | 0 | — |
case-17 | pass→pass | 7,532 | 5,153 | -32% | 1 | 1 | 0% | 1,394 | 1,589 | +14% | 0 | 0 | — |
case-18 | pass→pass | 6,867 | 4,836 | -30% | 1 | 1 | 0% | 1,123 | 1,431 | +27% | 0 | 0 | — |
case-19 | fail→pass | 3,966 | 3,343 | -16% | 1 | 1 | 0% | 676 | 1,303 | +93% | 0 | 0 | — |
case-21 | pass→pass | 3,024 | 3,134 | +4% | 1 | 1 | 0% | 498 | 1,299 | +161% | 0 | 0 | — |
case-22 | pass→pass | 9,942 | 8,027 | -19% | 1 | 1 | 0% | 1,733 | 2,215 | +28% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +5 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.