Skip to content
Skills Library
Data & analytics · Analysis

sql-analysis

/sql-analysis

Answer a quantitative business question by writing a SQL query against the data warehouse, validating it, and presenting the result. Use when the user asks "how many...", "what's the trend of...", "compare X vs Y over...", "what's our top N...", or anything that resolves to a query against tabular data. Produces a small result table plus the underlying query.

Licence
Apache-2.0
Last repository change
25.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 25.10.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What it does and when to use it

Answer a quantitative business question by writing a SQL query against the data warehouse, validating it, and presenting the result. Use when the user asks "how many...", "what's the trend of...", "compare X vs Y over...", "what's our top N...", or anything that resolves to a query against tabular data. Produces a small result table plus the underlying query.

Triggers from the description

how many...whatcompare X vs Y over...
Original author description

Answer a quantitative business question by writing a SQL query against the data warehouse, validating it, and presenting the result. Use when the user asks "how many...", "what's the trend of...", "compare X vs Y over...", "what's our top N...", or anything that resolves to a query against tabular data. Produces a small result table plus the underlying query.

How it works

  1. Steps
  2. Anti-patterns
  3. When to delegate
Original SKILL.md headings · 71 lines, 465 words
SKILL.md preview
---
name: sql-analysis
description: Answer a quantitative business question by writing a SQL query against the data warehouse, validating it, and presenting the result. Use when the user asks "how many...", "what's the trend of...", "compare X vs Y over...", "what's our top N...", or anything that resolves to a query against tabular data. Produces a small result table plus the underlying query.
---

# SQL Analysis Skill

Repeatable SOP for turning a business question into a verifiable SQL answer.

## Steps

1. **Restate the question as a metric.** In one sentence, write:
   *"<metric> by <grouping> over <time window>, filtered by <filter>"*.
   If any of those four (metric / grouping / window / filter) is missing or
   ambiguous, ask **one** clarifying question and stop. Do not guess.

2. **Locate the source.** Decide where the data lives:
   - Look in `knowledge/` first for any schema notes, data-dictionary entries,
     or prior query examples uploaded by the user.
   - If the right table is not obvious, **delegate to the `data-explorer`
     sub-agent** with the metric definition as the prompt — its job is to
     identify the canonical source.

3. **Draft the query.** Write the SQL in a fenced ```sql``` block. Conventions:
   - Always include the time window in a `WHERE` clause — never query the
     full history "just in case".
   - Always `SELECT` an explicit column list — never `SELECT *` in an answer.
   - Use CTEs (`WITH x AS (...)`) over nested subqueries for anything beyond
     two levels of nesting.
   - Comment any non-obvious filter (`-- excludes internal test accounts`).

4. **Validate before reporting.** Run the query and check:
   - Row count is in the ballpark you expected (1 row, 10 rows, ~30 daily
     buckets, etc.). A surprising row count is almost always a bug — investigate.
   - No `NULL`s in the grouping column unless that is the intended cohort.
   - At least one numeric sanity check: a known total, a known reference value,
     or a min/max range that matches reality.
   - If anything looks off, **do not report the number** — fix the query first.

5. **Write the report.** Use this exact structure:

   ```
   ## Answer
   <one-sentence direct answer with the headline number(s)>

   ## Result
   <small markdown table — at most ~15 rows; for longer results, summarise
   and offer to render a chart or attach the full CSV>

   ## Query
   ```sql
   <the exact query you ran>
   ```

   ## Sources & validation
   - **Table(s):** `schema.table_name` (row count, freshness if known)
   - **Validation:** <which sanity checks you ran and the result>
   - **Caveats:** <known data quality issues, missing dates, etc.>
   ```

## Anti-patterns

- ❌ Reporting a number without the query that produced it.
- ❌ Using `LIMIT N` to "make the output fit" without explaining what got cut.
- ❌ Reading a single row and reporting it as a trend.
- ❌ Inventing a table or column name. If unsure, delegate to `data-explorer`.

## When to delegate

- The user's question requires probing several candidate tables / sources
  before any query can be written → **spawn `data-explorer`**.
- The user wants a polished written deliverable summarising several analyses
  (e.g. "weekly health report") → **spawn `report-writer`** after you have
  the underlying numbers ready.

Versions

RepositoryScoreLicence
This page · agentscope-ai/agentscope-java100Apache-2.0
ajitpratap0/gosqlx100Apache-2.0

Database snapshot: 13.11.2026 · package version 8bc6b4a2907c (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100sql-query-optimizer
    Optimize sql query optimizer operations. Auto-activating skill for Data Analytics. Triggers on: sql query optimizer, sql query optimizer Part of the Data Analytics skill category. Use when working with sql query optimizer functionality. Trigger with phrases like "sql query…
  • 100ask
    Use when the user asks a data question, wants to run a query against a data product, chat with an AI agent, or invoke a tool. Triggers: run SQL, run a query against a data product, ask agent, chat with agent, execute query, invoke tool, call tool, get answer, analyze data, how…
  • 100write-query
    Write a SQL query or dbt model that answers a business question correctly: look up the business objects and measures in Konstruct's ontology, take the approved definition with its required filters and grain from define, and join only along the relationships the ontology lists.…
  • 100write-query
    Write a SQL query or dbt model that answers a business question correctly: look up the business objects and measures in Konstruct's ontology, take the approved definition with its required filters and grain from define, and join only along the relationships the ontology lists.…
  • 100sql-to-insights
    Turns SQL query results into a decision-ready business narrative - headline finding, drivers, recommendation - plus the right chart choice for the data shape. Use when someone asks "what does this data actually mean", "summarize these query results for the exec team", "what…
  • 100retail-analytics-concierge
    Translates natural language questions into SQL queries, executes against the connected data warehouse, and presents results with visualizations. Enables non-technical retail users to self-serve analytics without writing SQL. Use when asked to 'how many units did we sell', 'show…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.