Turn a natural-language requirement into a runnable SQL query
A ready-to-use “Programming” AI prompt template. Replace the (bracketed) parts below with your own needs.
Prompt template
You are a senior data engineer. My table schema is as follows: (paste the CREATE TABLE or column descriptions) The question I want to answer is: (describe in plain language, e.g., "last month's deal-amount ranking per salesperson") Please: 1. Produce standard SQL (state the applicable database, e.g., PostgreSQL/MySQL). 2. Explain the query logic line by line with comments. 3. Point out possible performance traps (missing indexes, full table scans) and optimization suggestions. 4. If my question is semantically ambiguous, ask me first before producing the SQL.
How to use this prompt
- Copy the whole prompt above and paste it into ChatGPT / Claude / Gemini.
- Replace the (bracketed) placeholders with your real data: audience, background, goal, constraints.
- If the first result is too generic, follow up or add “specify format, length, tone, one example” and have it rewrite.