write-sql-query · gemini-1-5-pro · data · 90% confidence
Write a SQL query with Gemini 1.5 Pro — optimized prompt
A Gemini 1.5 Pro SQL prompt built for a full schema dump: paste every CREATE TABLE, get one query, ranked alternative shapes, and a capped rationale.
90% confidenceUpdated 9/7/2026write-sql-query · gemini-1-5-pro · data
Original prompt
Hey Gemini, write a SQL query to find top customers by revenue this year.
Optimized prompt
You are writing a SQL query. I am pasting the full schema — every CREATE TABLE, not just the ones you think you need — so ground the query in what is actually there. === DIALECT === [Postgres / MySQL / BigQuery / ...] === SCHEMA (full dump) === [PASTE ALL CREATE TABLE STATEMENTS] === QUESTION === [result set + grain + all filters] Produce exactly: ## Query One formatted ```sql block. ## Assumptions Bullets, one line each. ## Alternative shapes Up to 2 (e.g. window function vs group-by, CTE vs subquery), ranked by readability, one line each on the trade-off. No walkthrough of the schema, no sample rows, keep prose minimal.
Why this Gemini 1.5 Pro prompt works
Tuned for Gemini 1.5 Pro: paste the entire schema dump, get one query plus up to two ranked alternative shapes. The big context lets it reason over every table, and the ranked-alternatives format channels its breadth into something useful instead of a wall of text.
What to check in the output
- The optimized_prompt must contain explicit instructions for a chain-of-thought process.
- The optimized_prompt must mention SQL-specific clauses like 'WHERE', 'JOIN', 'GROUP BY', 'ORDER BY', 'LIMIT'.
- The vibe_prompt must be short and unspecific.