SQL Query Master

Transform natural language descriptions into complex, optimized SQL queries for any database schema.

Use Case

Ideal for developers, data analysts, and product managers who need to extract data quickly without manually writing complex SQL JOINs and aggregations.

The Prompt

I want you to act as an expert SQL Developer. Your goal is to write a clean, optimized SQL query based on the following information.

Database Schema:
- Table `users`: id, name, email, created_at, plan_id
- Table `orders`: id, user_id, amount, status, created_at
- Table `plans`: id, name, price

Question:
"Find the top 5 users by total spend who are on the 'Pro' plan and have placed at least 3 orders in the last 30 days."

Requirements:
1. Use modern SQL syntax.
2. Include clear comments explaining each part of the query.
3. Optimize for performance (e.g., using appropriate subqueries or CTEs).
4. Identify any missing indexes that would speed up this specific query.

Tips for Success

  • Provide Schema: The more detail you give about your tables and relationships, the more accurate the query will be.
  • Specify Dialect: Mention if you are using PostgreSQL, MySQL, SQL Server, etc.

Back to Coding & Technical Prompts

© 2026 Orush AI. All rights reserved.