Skip to content

SQL

SQL Query From a Plain-English Ask

AI Tool: ChatGPTCategory: Data & Analytics

Translate a business question into SQL with joins, grain warnings, and a check query.

The Prompt

Write SQL for this question. State grain and join assumptions.

Question: {{question}}
Warehouse / dialect: {{dialect}}
Tables I have (names + key columns):
{{schema}}
Filters: {{filters}}
Need: {{need}}

Return:
1. Assumptions (grain, time zone, inclusive dates)
2. The query, readable CTEs, no SELECT *
3. How I should sanity-check the result (counts or a duplicate check)
4. Indexes / partition filters to respect if obvious from {{schema}}

If the schema cannot answer the question, do not guess columns — list what is missing.

Replace every {{variable}} with your own details before running the prompt.

Variables to fill in

5 variables

{{question}}required
What you want to know.
{{dialect}}
Postgres, BigQuery, Snowflake, etc.
{{schema}}required
Tables and key columns.
{{filters}}
Date range, segment, etc.
{{need}}
One row per user, daily trend, funnel, etc.

Scroll to see every variable.

Best for

  • Analysts
  • Data engineers
  • PMs