Write a SQL query from plain English
Describe what you need and get a SQL query that matches your schema.
The prompt
Write a SQL query for [database: PostgreSQL / MySQL / SQL Server / SQLite]. Tables: [paste CREATE TABLE statements or column lists] What I need: [plain-English description, e.g. "top 10 customers by total spend in 2025, with their email and number of orders"] Explain each part of the query, mention any indexes that would help performance, and point out edge cases (e.g. NULLs, ties).
How to use this prompt
- Select Copy prompt.
- Paste it into your AI assistant (ChatGPT, Claude, Gemini, Copilot or similar).
- Replace every part in [square brackets] with your own details before sending.
- Review the answer and ask for changes — the first reply is a draft.
Tip: Test on a copy of your data. Check that joins don't duplicate rows.
Example output (excerpt)
An illustrative excerpt written by our editors to show the expected shape of a good answer. Your results will differ.
SELECT c.id, c.email, COUNT(o.id) AS order_count, SUM(o.total) AS total_spend FROM customers c JOIN orders o ON o.customer_id = c.id WHERE o.created_at >= '2025-01-01' AND o.created_at < '2026-01-01' GROUP BY c.id, c.email ORDER BY total_spend DESC LIMIT 10;
Related prompts
Write a Python script with explanations
Get working Python code plus an explanation of how it works.
Write a Python script that [describe the task]. Input: [describe input data/format] Output: [describe expected output] Python version: [e.g. 3.12] Libraries allowed: [e.g. standard library only, pandas] Requirements: clear variable names, comments for non-obvious parts, error handling for [likely problems], and a small example of how to run it. After the code, explain how it works in plain English and list any assumptions you made.
How to use it
Run the code on test data first. Read the assumptions list and correct any that are wrong.
Clean a dataset with pandas
Generate pandas code to clean and summarise a messy CSV.
I have a CSV with these columns and sample rows: [paste column names and 5 sample rows — remove personal data] Problems I see: [e.g. missing values, mixed date formats, duplicates] Goal: [e.g. monthly sales totals by region] Write pandas code that loads the file, fixes these problems step by step with comments explaining each choice, and produces the goal output. Print row counts before and after each cleaning step so I can check nothing was lost unexpectedly.
How to use it
Never paste real customer data into an AI tool; use anonymised samples.
Explain this JavaScript code
Understand unfamiliar JavaScript line by line.
Explain this JavaScript code to someone with [beginner/intermediate] experience: ```js [paste code] ``` 1. Summarise what it does in 2 sentences. 2. Walk through it section by section. 3. Point out any bugs, security problems or outdated patterns. 4. Suggest one improvement with an example.
How to use it
Great for code you inherited or found online. Test any suggested change.