PromptDev

Write a SQL query from plain English

Hand over the schema and the question, get back a query that uses only your real columns — with its assumptions stated, not smuggled in.

Last updated

Fill in the blanks

Assembled in your browser — nothing you type is stored or sent anywhere.

Your prompt

Write a DuckDB query. Schema (the ONLY tables and columns that exist): orders(id, customer_id, total, created_at) customers(id, name, country, signed_up_at) Question to answer: the five countries with the highest average order value this year Rules: use only the tables and columns above — if the question needs data the schema doesn't have, say so instead of inventing a column. State any assumption you make (how NULLs are treated, what ties do, date boundaries) as comments in the query. Then explain in two sentences what the query does and where it could be slow on a large table.

Model-agnostic — works in Claude, ChatGPT, Gemini or any AI chat.

Why this prompt works

  • Declaring the schema as exhaustive is the single biggest fix — without it, models cheerfully JOIN to tables that don't exist.
  • Assumptions-as-comments puts the judgement calls (NULLs, ties, "this year") where the next reader of the query will actually see them.
  • The performance sentence catches the accidental full-table scan while the query is still in a chat window instead of a dashboard.

Related in Prompts