AI Agent Hub
Back to skills
SQL Query Assistant icon

SQL Query Assistant

Development Updated 2026.08.30

Paste the following prompt into your AI chat to install this skill:

Please install @user_70c2f807/sql-query-assistant according to https://skillhub.cn/install/skillhub.md.

About this skill

Reducing the Handoff Between Product and Data Teams

Product, operations, and analysts often need data, but the blocker is rarely the business question. It is the missing table names, ambiguous fields, and SQL syntax such as JOIN, subqueries, and window functions. SQL Query Assistant targets that handoff: it turns a natural-language data request into an executable SQL draft and explains the logic, so users can verify results before asking engineers or DBAs for deeper help.

How It Works

The skill starts by clarifying the query goal, target tables, key fields, filters, and grouping dimensions. It then generates formatted SQL, including common patterns such as SELECT, JOIN, subqueries, and window functions. After generation, it annotates the logic line by line, provides an expected output example, and flags compatibility or performance concerns. It can adapt syntax for MySQL, PostgreSQL, SQL Server, and Hive, suggest indexes, offer alternative query shapes, and analyze existing slow SQL. It is especially useful for business metrics, reporting queries, and review-friendly SQL drafts.

Boundaries

It does not connect to a database and does not execute SQL. If table schemas are unclear, multi-table join keys are unknown, or the query involves production UPDATE and DELETE statements, the user should validate scope first. It is not intended for database design, operations, ETL orchestration, or NoSQL querying.

Use Cases

  • Product or operations owners turn recent-30-day channel new-user requests into MySQL SQL after providing table names and fields.
  • Analysts ask for line-by-line explanations of broken or slow SQL, plus index and rewrite suggestions.
  • Data staff draft retention or conversion queries and confirm multi-table JOIN keys and NULL handling.
  • Engineers generate annotated PostgreSQL queries and expected output samples before validating reporting metrics in a test environment.

Best For

  • Product and operations owners who need self-service data pulls without writing complex SQL
  • Analysts who reconcile reporting metrics, JOIN logic, and NULL handling
  • Backend engineers reviewing slow queries and index strategies
  • Data analysts drafting business metric SQL and expected output samples