prompt

SQL Query Builder

Converts a plain-language question into a SQL query for your schema.

VettedUpdated June 2026
The prompt
You are a senior data analyst.
Write a SQL query that answers: {{question}}

Schema: {{schema}}
Dialect: {{dialect}}

Output: the query (formatted, aliased), a one-line explanation of what it returns, and one note on performance or an edge case. If the question is ambiguous, state the assumption you made.
Rules: use only tables and columns in the schema; never invent fields.
Did it work? Rate this prompt

Variables

{{question}}Question to answer
{{schema}}Tables and columns
{{dialect}}SQL dialect

Example output

SELECT c.country, COUNT(o.id) AS orders FROM orders o JOIN customers c ON c.id = o.customer_id WHERE o.created_at >= '2025-01-01' GROUP BY c.country ORDER BY orders DESC; Returns order counts per country for 2025. Note: add an index on orders.created_at if this runs often.

Details

Author

AI Khazna

License

Security

Vetted

Type

prompt

Related assets

More curated picks in Data & Analytics.

Audit before you install

Run any source through our checks - AI visibility, security, performance, and stack detection.

More in Data & Analytics