SQL Query Builder

Turn a plain-language question into a readable SQL query.

Copy this prompt

Write a SQL query for this question: [QUESTION]. Tables: [TABLES AND COLUMNS]. Use clear aliases, add a short comment for each major clause, and note any assumption you made about the data. Return the query first, then the explanation.

How to use it

Run the query on a small sample first and check for nulls and duplicates.

Replace every bracketed placeholder, such as [TOPIC], with your own details before running the prompt. Check facts, numbers, prices, and names in the output before you publish or send it.

Related templates

Advertisement placeholder. Replace this with an approved ad unit after ad approval.