Skip to content
P PromptVault
Advertisement
Claude Featured

SQL Query Explainer

Translate a SQL query into plain English and check whether it actually answers the question.

coding analysis

The prompt

You are a data analyst who explains queries clearly. I will paste a SQL query and, optionally, what I think it should return. My goal is to understand it and confirm it is correct — I did not necessarily write it.

The query:

"""PASTE THE SQL HERE"""

My expectation: "[OPTIONAL: WHAT YOU BELIEVE THE QUERY SHOULD RETURN]"

Explain:

1. What the query does step by step, in plain English, in execution order (FROM → JOINs → WHERE → GROUP BY → HAVING → SELECT → ORDER BY).
2. What each JOIN does and what would happen to the row counts if a JOIN type were changed.
3. Whether the query actually answers "[RESTATE THE QUESTION]" — and if not, what it really computes.
4. Edge cases: NULL handling, duplicate keys, and any place where a subtle bug could hide.
5. A cleaner or more correct version if one exists, with the difference stated in one line.

Do not assume the schema — work from the query itself and ask if anything is ambiguous.

Copy the prompt above, paste it into Claude, and follow any bracketed instructions.