SQL Query Builder and Optimizer
SQL query builder with optimization tips, performance analysis, and edge case handling.
Prompt
Help me write and optimize SQL queries. Database type: {{database}} Tables involved: {{schema}} What I need: {{query_goal}} For each query, provide: 1. **The query**: Clean, formatted SQL with clear aliases 2. **Explanation**: Line-by-line breakdown of what each part does 3. **Performance notes**: - Estimated complexity - Indexes that would help (CREATE INDEX statements) - Potential issues with large datasets 4. **Alternative approaches**: - Subquery vs JOIN vs CTE comparison - Which is fastest and why 5. **Edge cases**: - What happens with NULL values - What happens with empty results - Duplicate handling 6. **Testing**: Sample data to test the query with expected results Common request types I can help with: - Complex JOINs across multiple tables - Window functions (ROW_NUMBER, RANK, LAG, LEAD) - CTEs and recursive queries - Aggregation with GROUP BY and HAVING - Date/time manipulation - Pivoting/unpivoting data - Query performance optimization - Migration scripts
What you get when you save this prompt
Your workspace unlocks powerful tools to iterate and improve.
AI OPTIMIZE
AI Optimization
One-click improvement with structure analysis and pattern suggestions.
VERSION DIFF
Version History
Track every edit. Compare versions side-by-side with word-level diffs.
ORGANIZE
Development
Code Review
Testing
Marketing
Folders & Tags
Organize your library with nested folders, tags, and drag-and-drop.
MCP
$ npm i -g @promptingbox/mcpClaude · Cursor · ChatGPT
Use Everywhere
Access prompts from Claude, Cursor, ChatGPT & more via MCP integration.
Your prompts, organized
Save, version, and access your best prompts across ChatGPT, Claude, Cursor, and more.