SQL Query Writer
Providing the full schema and relationships eliminates guesswork. Asking for comments and assumption flags makes the output reviewable and trustworthy before running against production.
Write a SQL query for {{database_type}} to answer this question: "{{business_question}}" Table schema: {{table_schema}} Table relationships: {{relationships}} Requirements: - Use clear aliases for all tables and columns - Add comments explaining each major section of the query - Handle NULL values appropriately - Optimize for readability over cleverness - If the query requires aggregation, include a GROUP BY with the most useful breakdown - Return results ordered by {{order_preference}} After the query, explain what each section does and flag any assumptions you made about the data.
Variables to customize
Why this prompt works
Providing the full schema and relationships eliminates guesswork. Asking for comments and assumption flags makes the output reviewable and trustworthy before running against production.
What you get when you save this prompt
Your workspace unlocks powerful tools to iterate and improve.
AI Optimization
One-click improvement with structure analysis and pattern suggestions.
Version History
Track every edit. Compare versions side-by-side with word-level diffs.
Folders & Tags
Organize your library with nested folders, tags, and drag-and-drop.
$ npm i -g @promptingbox/mcpUse 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.