SQL Query Builder

Write a prompt that generates correct SQL from natural language.

intermediate
40 points
coding

Instructions

Create a prompt that takes a natural language question about a database and generates the correct SQL query. Your prompt should include the table schema and handle JOINs, GROUP BY, and WHERE clauses. Test with: "Show me the top 5 customers by total order amount in the last 30 days."

Sample input

Your prompt is run on this input, and both the result and your prompt are graded against the goal below. Put {input} in your prompt where the sample should go, or just write instructions and the sample is sent right after them.

Top 5 customers by total order amount in last 30 days. Tables: customers(id, name, email), orders(id, customer_id, amount, created_at)

Goal: SELECT c.name, SUM(o.amount) as total FROM customers c JOIN orders o ON c.id = o.customer_id WHERE o.created_at >= NOW() - INTERVAL 30 DAY GROUP BY c.id, c.name ORDER BY total DESC LIMIT 5

Hints

AI-Powered Hints

Smart

Get personalized hints based on your current progress. Start with gentle hints and progress to more detailed ones.

Tags

sql
database
natural-language

Access Level

FREE