Write A SQL Query For Analysis
Describe the database engine, the available tables with their columns and relationships, the analysis you need in plain English, and whether to optimize for large tables or readability, and this prompt writes the production-ready SQL query to get there. It handles nulls sensibly, uses CTEs to keep complex logic readable, comments any non-obvious steps, and returns business-friendly column names instead of raw database_column_names — useful whenever you know the analysis you want but not the SQL to write it.
Write a SQL query for this analysis: Database: {database_type} Tables available: {tables} What I need: {analysis_request} Requirements: - Handle nulls sensibly - Use CTEs if the logic is complex, for readability - Comment any non-obvious logic - Optimize for {optimization_priority} - Return business-friendly column names, not raw database_column_names