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.
Save this prompt to your library
Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.
Related prompts
Requiring before/after logging and a summary report turns a cleaning script into an auditable process. Flagging rows for manual review prevents silent data loss.
Visualization RecommendationStarting from the insight rather than the chart type ensures the visualization serves the story. Asking for common mistakes prevents the most frequent data viz errors.
Statistical Analysis GuideListing confounders and asking for assumption checks prevents the common mistake of running a test on data that violates its assumptions. The plain-English interpretation ensures you understand the results.
Dashboard Design SpecDefining the key questions the dashboard must answer at a glance prevents scope creep and ensures every widget earns its space. Specifying the audience expertise level calibrates complexity.