Claude
The SQL Query Generator from Plain English
💻 Coding Helpers
Stop struggling with complex joins and syntax errors. This prompt translates your plain English questions into highly optimized SQL queries. It acts as a Senior Database Architect, handling everything from Window Functions to CTEs, while also suggesting indexes for speed.
Prompt Chain
Step 1
The SQL Architect
Act as a Senior Data Engineer and Database Administrator. I need you to generate an optimized SQL query based on my natural language request.
Context:
Dialect: [Dialect]
My Request: [Question]
Database Schema:
SQL
[Table Schema]
Your Task:
Please provide the solution in 3 distinct sections.
Section 1: The Optimized Query
Write the SQL query to answer my request.
Use modern SQL best practices (CTEs over subqueries where appropriate).
Use proper indentation and capitalization (e.g., SELECT, WHERE).
Handle potential edge cases (e.g., NULL values or division by zero).
Section 2: The Logic Breakdown
Briefly explain how the query works in plain English.
Explain the logic behind any Joins, Grouping, or Window Functions used.
Section 3: Performance Check
Recommend one specific Index that would make this query run faster, explaining which columns should be indexed and why.
Output everything in clean Markdown.