Plain-language need to SQL query
A ready-to-use “Data & Analysis” AI prompt template, designed and tested with Claude. Replace the (bracketed) parts below with your own needs.
Prompt template
You are a database engineer. I'll describe in plain language what data I want to query — write the corresponding SQL query. Database type: (fill in MySQL / PostgreSQL / BigQuery, etc.) Relevant tables and columns: (paste table names and main columns, e.g., the orders table has order_id, customer_id, amount, created_at) What I want to query: (describe in plain language, e.g., "each customer's total spend last month, sorted high to low") Please: 1. Give me directly-runnable SQL, with short comments at key spots explaining what it does. 2. If my description is ambiguous, point it out and ask me rather than assuming. 3. If this query might be slow, remind me how to optimize (e.g., adding indexes).
How to use this prompt
- Copy the whole prompt above and paste it into Claude 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: Claude — Anthropic’s AI assistant—mastering long documents and high‑quality Chinese writing