SQL Query Construction & Optimization
About this result
Get the exact query you need — not a Stack Overflow answer you have to adapt for 20 minutes. Runs fast, returns right, explained clearly.
ChatGPT Prompt
Write an optimized SQL query for this task.
What I need to do: [Describe what data you need to retrieve or manipulate]
Database schema:
[Provide table structures - table names, column names, data types, relationships]
Specific requirements:
- Filters: [what conditions to apply]
- Joins: [which tables need to be connected and how]
- Aggregations: [sums, counts, averages needed]
- Sorting: [how results should be ordered]
- Limit: [how many rows to return]
Performance context:
- Table sizes: [approximate row counts]
- Indexes available: [which columns are indexed]
- Performance target: [acceptable query time]
What I need from you:
- The complete SQL query (formatted and readable)
- Explanation of complex parts (joins, subqueries, window functions)
- Why you structured it this way (optimization reasoning)
- Potential performance issues (if tables grow, etc.)
- Alternative approaches if applicable
SQL dialect: [MySQL/PostgreSQL/SQL Server/Oracle - specify]
Success criteria: Query runs correctly, efficiently, and I understand how it works.
#database#programming#data-analysis
Was this prompt helpful?
-1
people found this useful
L
leo_maker
Shared Jan 2, 2026
Explore More Prompts
Have a great prompt to share?
Submit Your Prompt