Agent skill · data analytics · aiskillstore

sql-patterns

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.

Why this skill is useful

Codifies common SQL patterns and strategies that the AI could infer but now doesn't have to guess.

What it needs

About 2k tokens when loaded. Last updated 2026-08-07. 405 stars on the source repository.

What this skill does

SQL Patterns Quick reference for common SQL patterns. CTE (Common Table Expressions) Chained CTEs Window Functions (Quick Reference) Function Use ---------- ----- ROWNUMBER() Unique sequential numbering RANK() Rank with gaps (1, 2, 2, 4) DENSERANK() 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 JOIN Reference 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 Pagination Index Quick Reference Index Type Best For ------------ ---------- B-tree Range queries, ORDER BY Hash Exact equality only GIN Arrays, JSONB, full-text Covering Avoid table lookup Anti-Patterns 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 Additional Resources For detailed patterns, load: ./references/window-functions.md - Complete window function patterns ./references/indexing-strategies.md - Index types, covering indexes, optimization

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills aiskillstore/sql-patterns

View the source on GitHub

Browse the @skills marketplace