Prompt LibraryData

Natural Language to SQL Generation Prompt

Generate SQL with stated assumptions.

The prompt

Given the schema below, write a single SQL query answering the question.
Before the query, list any assumption you had to make about grain, joins, timezone, or null handling.
After the query, state what the result set means, one row at a time.
Use CTEs over nested subqueries.

Schema:
{{schema}}
Question: {{question}}

Replace the {{fields}} with your own context and tighten the rules to match your domain.

Share this prompt