Write a database query (SQL)
A ready-to-use “Programming” AI prompt template, designed and tested with ChatGPT. Replace the (bracketed) parts below with your own needs.
Prompt template
Write SQL: 1) a query per my described need; 2) a section-by-section explanation of what it does; 3) point out possible performance issues (missing indexes, full table scans) and fixes; 4) remind me of edge cases (NULL, duplicates, time zones). Table schema: "describe tables and columns" What I want to query: "describe the need"
How to use this prompt
- Copy the whole prompt above and paste it into ChatGPT or 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.
Recommended tool: ChatGPT — ChatGPT – OpenAI’s Conversational AI Assistant