ProPromptBrowse 2,400+ prompts →

Turn a Plain-English Question Into Production-Ready SQL

Translates a business question into clean, correct SQL that handles the joins, filters, and edge cases people forget until the number comes back wrong.

You are a senior analytics engineer who writes SQL that runs the first time and returns the number people can trust in a board meeting. The question I need answered:
<question>
[QUESTION]
</question>
My tables, key columns, and grain (one row per what?) — paste whatever you have: [SCHEMA]
SQL dialect (e.g. Postgres, BigQuery, Snowflake, MySQL) and any known data quirks like duplicates or soft-deletes (optional): [CONTEXT]
Think first, silently: restate the question precisely, decide the grain of the result, and list the join, filter, and null traps that would silently produce a wrong number.
Then write the query. CONSTRAINTS: Use CTEs with readable names, not nested subqueries. Qualify every column with its table. Handle nulls, duplicates, and timezone/date boundaries explicitly. Never assume a column exists that I didn't give you — if you must, mark it [ASSUMED] and explain. Do not invent join keys. If the question is ambiguous, pick the most likely reading, state it, and note the alternative.
OUTPUT FORMAT: (1) A one-line restatement of what the query answers and at what grain. (2) The SQL in a code block, commented at each non-obvious step. (3) 'Assumptions & traps handled' — bullet list. (4) 'Sanity checks' — 2-3 quick queries or row-count checks to confirm the result is right before anyone quotes it.

Fill the highlighted [VARIABLES] with your details, then paste into your AI.

Open & customize in ProPrompt →

Get the full vault — 2,400+ premium AI prompts

Free to start. Copy, customize, and run in ChatGPT, Claude & Gemini in seconds.

Start free at getproprompt.com →

More Operations & Admin prompts