SQL Generation

intermediatedataMin 16K context

Generates optimized SQL queries from natural language descriptions. Supports multiple dialects (PostgreSQL, MySQL, SQLite, SQL Server), handles complex joins, subqueries, window functions, and CTEs. Includes query explanation and performance optimization hints.

Use Cases

  • Converting business questions to SQL queries
  • Optimizing slow queries with EXPLAIN analysis
  • Generating migration scripts
  • Building complex reporting queries
  • Database schema design from requirements

Example Prompt

Generate a PostgreSQL query for the following requirement:

"Find the top 10 customers by total order value in the last 30 days,
including their order count and average order value. Exclude customers
who have any cancelled orders."

Schema context:
- customers (id, name, email, created_at)
- orders (id, customer_id, total, status, created_at)

Requirements:
- Use CTEs for readability
- Include performance hints (indexes to consider)
- Explain the query logic step by step

Recommended Models

Compatible Tools

claude-codecursorgithub-copilotkiroany

Modalities

Input: text
Output: code, text

Related Skills

Author

OpenModels Community

@openmodelsrun