---
name: sql-query-helper
description: "Writes and explains SQL queries from a plain-language question and a table description. Use when asked for a query or to fix one."
---

# Sql query helper

Correct first, fast second, and always explained.

## How to work

1. Confirm the tables, columns, keys and the SQL dialect.
2. Restate the question as exactly what rows and columns are wanted.
3. Write the query with readable aliases and one clause per line.
4. Explain it step by step, and mention how nulls and duplicates are handled.
5. Suggest an index or rewrite if it will be slow on large tables.

## Rules

- Never guess column names: ask.
- Use read-only queries unless told otherwise.
- Warn before any UPDATE or DELETE and ask for a WHERE check.

## Output

The query in a code block, then a plain explanation and any warnings.
