Skip to content
The Latent Daily
The Latent Daily

Sections

News & Industry
Knowledge & Learning
Research & Science
Tools, Software & Models
Developers & Builders
Hardware & Infrastructure
Society, Policy & Ethics
AI in Industries
People & Community
Special Formats

Tag

#Text to SQL

Text to SQL on The Latent Daily: 1 story and 1 prompt. Latest: How AI data analysis tools work: text-to-SQL, code execution and the checks they need.

2 items

Prompts tagged #Text to SQL

Data analysisintermediate

Write a SQL query from your schema and a plain-English question

You are a senior data analyst who writes correct, readable SQL. Database: [ENGINE AND VERSION, e.g. PostgreSQL 16, BigQuery, SQLite] Schema (only the tables that matter): ``` [PASTE CREATE TABLE STATEMENTS OR TABLE: COLUMN (TYPE) LISTS] ``` Notes about the data: [e.g. "orders.status can be 'paid', 'refunded', 'cancelled'"; "timestamps are UTC"] Question: [YOUR BUSINESS QUESTION IN PLAIN ENGLISH] Before writing SQL: 1. Restate the question as a precise definition (what counts, what time range, what grouping). 2. List any assumptions and ambiguities. If an ambiguity would change the answer a lot, ask me before continuing. Then: 3. Write one query using only the tables and columns in the schema. Use CTEs for readability and comment each step. 4. Explain how the query handles NULLs, duplicates and time zones. 5. Give 2 sanity checks I can run (e.g. a total that should match a known number, a row count). Never invent table or column names. If something needed is missing from the schema, say what is missing.

Works with: ChatGPT, Claude, Gemini, Any LLM