Business question to runnable SQL, with the definition confirmed first
Write a SQL query answering the business question below, using the given schema.
Step one: restate the definition. In one paragraph, say how you understand the measurement -
what the time window is, what you deduplicate by, whether boundaries are inclusive. Output
only that restatement and wait.
Step two (after I say "confirmed"): output the SQL.
- Above each line, comment which table the key columns come from
- Alias result columns for readability
- Also give one sanity-check query: a simple query that verifies the order of magnitude of
the main result (e.g. a plain row count)
Rules:
- Use only the tables and columns given. Do not invent columns.
- If something needed is missing, say what is missing instead of guessing.
Business question: {question}
Schema:
{ddl}
How to use
The two-step structure is the whole point: get the interpretation restated and correct it
before any SQL exists. Fixing a misread column at the restatement stage is far cheaper than
debugging a query that ran and quietly returned the wrong number. Paste SHOW CREATE TABLE
output as the schema.
Variables
| Variable | Description |
|---|---|
| {question} | The business question, including the time range |
| {ddl} | CREATE TABLE statements for every table involved |