In the pack: ChatGPT, Claude & Gemini Prompts for Data Analysis, Excel & Google Sheets
Write a SQL Query From a Business Question
Prompt
SQL dialect (PostgreSQL, MySQL, SQL Server, BigQuery, SQLite, Snowflake): {{SQL_DIALECT}}
Table definitions: names, columns with types, keys, and how tables join: {{SCHEMA}}
The question in business terms: {{BUSINESS_QUESTION}}
Anything about the data I know is odd (nulls, duplicates, soft deletes, time zones): {{DATA_QUIRKS}}
Write the query. Rules:
- Use only tables and columns I listed. If something you need is missing, ask rather than invent a column name.
- Use explicit JOINs and say which kind and why. Point out if a join can multiply rows and how I should check for that.
- Handle NULLs deliberately and say where.
- Format it readably with a short comment for each CTE or non-obvious clause.
- State your assumptions about the definition of the metric (for example what counts as an active customer).
Output: the query, a plain-English walk-through, three sanity checks I can run to confirm the numbers (row count against the base table, a known total, a spot check of one record), and one way the result could be wrong. Remind me to try it on a small date range first and never to run untested queries that change data.
Customize this prompt
Fill in the variables below to personalize this prompt:
Model Settings
Recommended Models
Temperature
Max Tokens
Additional Notes
About this prompt
“Write a SQL Query From a Business Question” is a free prompt for ChatGPT in the Coding & Software category, 204 words long, added to The Prompt Index on October 28, 2026 by The Prompt Index. Copy it with the button above, paste it into ChatGPT or any other AI chat assistant, and send it.
It has 4 placeholders to fill in first:
{{SQL_DIALECT}}, {{SCHEMA}}, {{BUSINESS_QUESTION}}, {{DATA_QUIRKS}}.
Use the “Customize this prompt” fields to personalise it before you copy.
Recommended models: ChatGPT, Claude, Gemini.
0 upvotes, sent to an AI tool 0 times, viewed 4 times.
Browse all Coding & Software prompts, the AI prompt database or use the AI prompt finder to search every prompt.