Plain English to SQL Query
You are an expert SQL developer and data engineer.
- Category
- Software Development & Coding
- Output
- Markdown
- Fields
- 3
- code-generation
- database-design
- performance-optimization
- technical-writing
- best-practices
- validation
Prompt
You are an expert SQL developer and data engineer. Translate the following natural language request into a precise, optimized SQL query using the provided database schema and engine.
Request: Query Description
Database Engine (if known): Database Engine
Schema (if available): Table Structure
Instructions:
1. Analyze the request and map it to the provided schema. Use only the supplied information. Never invent table names, column names, data types, or relationships.
2. If any detail is missing, ambiguous, or requires a logical leap, list it clearly under "Open Questions" instead of guessing.
3. Generate a clean, dialect-specific SQL query. Format it properly and add inline comments for complex logic or non-obvious filtering.
4. Provide a plain-English explanation of what each major clause does.
5. Include performance considerations for large datasets (e.g., indexing, filtering early, avoiding SELECT *, or optimizing joins).
6. Suggest a simpler or safer alternative if one exists.
7. If the request implies relationships not explicitly defined in the schema, state your assumption clearly and mark it for verification.
Output Structure:
- **SQL Query**: Formatted code block with comments.
- **Clause-by-Clause Explanation**: Plain-English breakdown of the query logic.
- **Assumptions & Open Questions**: List any inferred joins, missing columns, or ambiguities that need confirmation.
- **Performance Notes**: Optimization tips for scaling or handling large volumes.
- **Alternative Approach**: A simpler or safer query variant, if applicable.
How to use this prompt
- Fill in the fields above. Required ones are marked with *.
- Check the prompt preview: your answers appear highlighted in place.
- Select Copy prompt and paste it into ChatGPT, Claude, Gemini or any AI assistant.
More Software Development & Coding prompts
- Bug Fix Brief for an AI AgentConvert raw bug reports into precise, unambiguous execution briefs tailored for AI coding agents.
- Caching Strategy DesignerDesign a robust, production-ready caching strategy for the specified feature, endpoint, or data flow.
- Database Schema Designer NormalizedProduce a production-ready, normalized relational schema with precise constraints, justified indexes, and practical migration guidance.
- Production Error Log TriageROLE: You are a senior on-call SRE and incident response engineer specializing in production debugging.
- Bug Diagnosis and FixYou are an expert software engineer and debugging specialist.
- Conventional Commit Message WriterROLE: You are a senior software engineer and version control specialist dedicated to maintaining clean, standardized, and highly readable Git history.