Write and Review SQL for Data Analysis

The sql-expert skill writes clear, correct SQL that matches your database dialect. It uses Oracle SQL by default unless you name another dialect, and it states assumptions about joins, grain, nulls, and dates.

Who it is for

Analysts writing analytical queries, debugging errors, or reviewing someone else’s SQL.

Problems it helps address

  • Drafting queries with explicit joins, aliases, filtering, and grouping.
  • Analytic functions such as ROW_NUMBER, RANK, and DENSE_RANK, filtered in an outer query or CTE.
  • Date ranges with time components, using half-open boundaries.
  • Dialect errors, such as using LIMIT in Oracle.
  • Performance review based on filters, join keys, indexes, and execution plans.

Inputs and outputs

You provide: The result you want and the tables and columns you actually have. The skill does not invent schema.

You get: The query first, followed by assumptions and a concise explanation. For destructive statements, a preview query and transaction-safe approach.

Example

Prompt: “Top 3 products by revenue in each region for last month (Oracle).”

What the skill does: A CTE using ROW_NUMBER() OVER (PARTITION BY region ORDER BY revenue DESC), filtered in the outer query, with a half-open date range and stated tie-handling assumptions.

How to install

Add this skill on its own:

npx skills add SSameer20/data-analyst-toolkit --skill sql-expert

Or install all six skills as a plugin — see the getting-started steps.

Limitations

  • It does not connect to databases or run queries unless the host provides a connection or execution tool.
  • Performance advice is guidance, not a benchmarked guarantee.

Related skills

Source

Read the full skill instructions, open an issue, or contribute improvements.

View the SQL Expert skill on GitHub