ChatGPT prompt to explain a SQL query to non-engineers

A community prompt that has ChatGPT explain a SQL query in plain words for a colleague who reads spreadsheets.

Model
ChatGPT
Task
Work
Source
Shared by @f on GitHub

@f, who maintains the prompts.chat collection, wrote this prompt for handing a query to a stakeholder. ChatGPT explains the business question the SQL answers, the tables and joins, filters and date ranges, and risks such as cartesian joins, missing filters or exposed personal data, then adds a one-paragraph executive summary. Paste your query in place of ${sql}; it is told not to rewrite the query unless you ask.

The prompt is quoted from @f’s entry in prompts.chat on GitHub.

Prompt
Explain this SQL for a non-engineer stakeholder.

SQL:
${sql}

Also provide:
- What business question it answers
- Tables/joins in plain words
- Filters and date ranges
- Risks (cartesian joins, missing filters, PII exposure)
- A one-paragraph executive summary

Assume the reader knows spreadsheets but not SQL. Do not rewrite the query unless asked.
What it produces
Has ChatGPT explain what a SQL query does in plain words, flag its risks and add an executive summary.
Parameters
Replace ${sql} with the query you want explained
Source link
github.com
Added

Questions

Who is the explanation written for?
A reader who knows spreadsheets but not SQL, such as a manager or client who has to trust the numbers.
Does it check the query for problems?
It lists risks, including cartesian joins, missing filters and exposure of personal data.
Will ChatGPT change my query?
No. The prompt says not to rewrite the query unless asked.

See also

Sources: each prompt is quoted from the official example or the public post linked on its page. Promptline is not affiliated with OpenAI, Anthropic, Google or Midjourney.

Promptline

What are you looking for?

Search by headline, topic or keyword.