Question to SQL, with the assumptions spelled out

Turns a business question into a query plus the schema assumptions it made.

Coding sqlanalyticsdata Verified 2026-11-02

When to use it

When someone asks for a number and you need to know what they actually mean.

The prompt

Copy into your assistant
Turn this question into SQL against the schema below.

Output, in this order:
1. The question restated in one sentence, including the time window and the unit.
2. Assumptions you are making that the schema does not settle (NULL handling, duplicates, timezone, deleted rows).
3. The query.
4. What the result would look suspiciously like if one assumption were wrong.

Rules:
- Use only columns that exist in the schema. If a needed column is missing, say so instead of inventing one.
- If the question is ambiguous in a way that changes the answer, ask before writing SQL.

Question:
<question>

Schema:
<schema>

What to change

Paste the real DDL, not a description of it. Described schemas produce queries against columns that do not exist.

Why it works

Item 4 is the useful one: it tells you how to sanity-check the number before reporting it upward, which is where most analytics mistakes actually surface.

More coding prompts

Going deeper

More prompts

All prompts