sql
Skill15 starsChanged 41 days agoMITView on GitHub
Expert SQL assistance covering ANSI SQL, CTEs, Window Functions, aggregation, indexing, and query optimization. Use when writing complex analytical queries, tuning query execution plans, or designing databases.
15 other projects use a version of this.
Adopted by
Most recently taken up by
- base58ed/claude_code_filestheir own version, first seen Oct 20, 2026
- nimadorostkar/Claude-Skills-collectiontheir own version, first seen Oct 13, 2026
- zeeshanalimughal/claude-skillstheir own version, first seen Oct 13, 2026
- BrendenKennedy/claude-for-ai-platformstheir own version, first seen Oct 13, 2026
- sendou-ink/sendou.inktheir own version, first seen Oct 8, 2026
- SparkDevNetwork/Rocktheir own version, first seen Oct 8, 2026
Used with
Projects with it also use observability.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
OpenAISkillobservability
Vercel Observability expert guidance — Drains (logs, traces, speed insights, web analytics), Web Analytics, Speed Insights, runtime logs, custom events, OpenTelemetry integration, and monitoring dashboards. Use when instrumenting, debugging, or optimizing application performance and user experience on Vercel.
Also in 3 projects that use this
Other versions15 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 15
- Zafer-Liu/Data-Analysis-Agent★ 2.6ksame name
- SparkDevNetwork/Rock★ 701same name
- sendou-ink/sendou.ink★ 303same name
- maragudk/skills★ 49same name
- nimadorostkar/Claude-Skills-collection★ 33same name
- redpanda-data/skills★ 8same name
- thechandanbhagat/claude-skills★ 8same name
- Spardutti/claude-skills★ 3same name
- ffsshhttiikk/opencode-agents-skills★ 2same name
- kimtth/agent-skill-100-lines-or-less★ 2same name
5 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository350 other files it gives its agents.
- airflowSkill
- catboostSkill
- claudeSkill
- comfyuiSkill
- cursor-aiSkill
- dalleSkill
- daskSkill
- dbtSkill
- deepseekSkill
- fastaiSkill
- geminiSkill
- github-copilotSkill
- huggingfaceSkill
- jaxSkill
- jupyterSkill
- kerasSkill
- langchainSkill
- lightgbmSkill
- llamaindexSkill
- llamaSkill
- matplotlibSkill
- midjourneySkill
- mistralSkill
- mlflowSkill
- nltkSkill
- numpySkill
- ollamaSkill
- openai-gptSkill
- opencvSkill
- pandasSkill
- perplexitySkill
- plotlySkill
- polarsSkill
- pytorchSkill
- raySkill
- scikit-learnSkill
- seabornSkill
- spacySkill
- sparkSkill
- stable-diffusionSkill
- tensorflowSkill
- vaexSkill
- weights-biasesSkill
- whisperSkill
- xgboostSkill
- api-gatewaySkill
- clean-architectureSkill
- cqrsSkill
- domain-driven-designSkill
- event-drivenSkill
- event-sourcingSkill
- graphqlSkill
- grpcSkill
- hexagonalSkill
- microservicesSkill
- modular-monolithSkill
- monolithSkill
- rest-apiSkill
- sagaSkill
- serverlessSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 1 is distinctive, and 4 are very specific to this project.
0
Common
Most of the 15 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 125
Use SQL window functions (OVER (PARTITION BY ...
- Distinctive: line 150
Always use parameterized queries and prepared statements in application code to completely neutralize SQL injection attacks.
- Very specific: line 153
Use appropriate column types: TIMESTAMPTZ for timestamps, NUMERIC/DECIMAL for financial currency, not floating point.
- Very specific: line 157
Use SELECT * in production application queries.
- Very specific: line 159
Run long-running batch migrations or table locks without timeouts (SET statement_timeout = '5s').
“Common” is measured: kept by at least 6 in 10 of the 15 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
SQL
Standard language for storing, manipulating and retrieving data in databases.
When to Use
- Relational Data Storage & ACID Transactions: Financial ledgers, ERP systems, e-commerce checkouts, and customer databases.
- Complex Analytical Queries & Aggregations: Generating multi-dimensional business reports, cohorts, and funnels.
- Hierarchical & Graph Data Traversal: Querying organizational charts, bills of materials, and parent-child trees using recursive CTEs.
- Semi-Structured Document Querying: Using native JSON/JSONB indexing and operators in modern relational engines like PostgreSQL.
Quick Start
-- Create Table
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name VARCHAR(100),
email VARCHAR(100) UNIQUE
);
-- Insert Data
INSERT INTO users (name, email) VALUES ('Alice', 'alice@example.com');
-- Query Data
SELECT * FROM users WHERE name = 'Alice';Core Concepts
Advanced Window Functions & Analytical Partitioning
Computing running totals, rankings, and lead/lag intervals across result partitions:
SELECT
order_id,
customer_id,
order_date,
amount_usd,
-- Running cumulative sum per customer
SUM(amount_usd) OVER (
PARTITION BY customer_id
ORDER BY order_date
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) AS running_total,
-- Rank customers by transaction size within their region
DENSE_RANK() OVER (
PARTITION BY region_code
ORDER BY amount_usd DESC
) AS regional_rank,
-- Difference from previous order
amount_usd - LAG(amount_usd, 1, 0.0) OVER (
PARTITION BY customer_id
ORDER BY order_date
) AS diff_from_prev_order
FROM orders
WHERE order_date >= '2026-01-01';Hierarchical Tree Traversal with Recursive Common Table Expressions (CTEs)
Traversing nested organizational charts or bill-of-materials structures:
WITH RECURSIVE org_tree AS (
-- Anchor member: top-level executives (no manager)
SELECT
employee_id,
manager_id,
full_name,
title,
1 AS depth,
full_name AS hierarchy_path
FROM employees
WHERE manager_id IS NULL
UNION ALL
-- Recursive member: join subordinates
SELECT
e.employee_id,
e.manager_id,
e.full_name,
e.title,
ot.depth + 1,
ot.hierarchy_path || ' -> ' || e.full_name
FROM employees e
INNER JOIN org_tree ot ON e.manager_id = ot.employee_id
)
SELECT * FROM org_tree ORDER BY hierarchy_path;JSONB Semi-Structured Operations & GIN Indexing
Querying nested payloads with indexed containment queries:
-- Create GIN index for high-speed containment lookup
CREATE INDEX idx_events_payload ON audit_events USING gin (payload jsonb_path_ops);
-- Query using JSONB operators
SELECT
event_id,
payload->>'action' AS action_name,
payload->'user'->>'email' AS user_email,
payload#>>'{metadata,ip_address}' AS client_ip
FROM audit_events
WHERE payload @> '{"action": "user.login", "status": "failed"}'
AND (payload->'retry_count')::int > 3;Common Patterns
Window Functions for Rolling Averages and Ranking
Problem: Computing running totals or ranking top performers requires multiple slow self-joins.
Solution:
Use SQL window functions (OVER (PARTITION BY ... ORDER BY ...)):
SELECT
order_date,
customer_id,
order_amount,
-- Running total per customer
SUM(order_amount) OVER (
PARTITION BY customer_id
ORDER BY order_date
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) as cumulative_spent,
-- Rank orders by size per customer
DENSE_RANK() OVER (
PARTITION BY customer_id
ORDER BY order_amount DESC
) as rank_by_amount
FROM orders;Best Practices
Do:
- Always use parameterized queries and prepared statements in application code to completely neutralize SQL injection attacks.
- Inspect query execution plans (
EXPLAIN (ANALYZE, BUFFERS)) to verify index usage and eliminate sequential table scans. - Enforce referential integrity using foreign keys with appropriate
ON DELETE RESTRICTorON DELETE CASCADErules. - Use appropriate column types:
TIMESTAMPTZfor timestamps,NUMERIC/DECIMALfor financial currency, not floating point.
Don't:
- Use
SELECT *in production application queries; explicitly declare only needed columns to reduce network overhead. - Perform calculations or wrap indexed columns in non-sargable functions in
WHEREclauses (e.g.WHERE DATE(created_at) = '2026-01-01'). - Run long-running batch migrations or table locks without timeouts (
SET statement_timeout = '5s').
Troubleshooting
| Error | Cause | Solution |
Column '...' must appear in the GROUP BY clause | Non-aggregated column in SELECT without being included in GROUP BY. | Add column to GROUP BY or apply an aggregate function (MIN, MAX). |
Subquery returns more than 1 row | Scalar subquery used with = operator returned multiple rows. | Replace = with IN or add LIMIT 1 in subquery. |
Division by zero | Mathematical division with zero in denominator. | Use NULLIF(denominator, 0) to return NULL instead of throwing error. |
References
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

