SQL (Structured Query Language) describes data and operations on data in a relational database. For analysis, an SQL query tells the database system which table-shaped result to produce. The database does the work of filtering and aggregating rows; a language model can help turn a plain-English question into the query. section 2.4.2 section 1.4.2
Imagine a table of computer games with columns for release year, publisher, genre, and sales. You might ask how many games were released in 2017 or which publisher had the highest average sales. SQL makes such questions executable against the stored data. section 5.2.2
SELECT [Columns or Aggregates] #1 FROM [List of tables] #2 WHERE [List of conditions] #3
This template separates the requested output (SELECT), source tables (FROM), and conditions that restrict rows (WHERE). section 5.2.2
Count games from a year
SELECT Count(*) FROM games WHERE year = 2017 counts rows in the games table whose year is 2017. Other queries can select columns, calculate values from sales columns, or aggregate results by publisher. section 5.2.2
To request a query from a language model, provide the question, identify the target system as SQLite, and describe the database structure—for example, with its CREATE TABLE command. The table and column names give the model information it needs to translate the question. A reusable prompt can keep the schema and instruction fixed while replacing the question. section 5.1 section 5.2.4
Database: #1 CREATE TABLE games(rank int, name text, platform text, year int, genre text, publisher text, americasales numeric, eusales numeric, japansales numeric, othersales numeric, globalsales numeric); Translate this question into SQL query: #2 [Question] #3
The prompt supplies the games table definition, an explicit translation instruction, and a placeholder for each new question. section 5.2.4
Treat the generated SQL as a proposal, not an answer. Check that it matches the question, then run it in the database. For example, a translator produces SELECT COUNT(*) FROM games; for “How many games are stored?”; executing it in SQLite returns 16,599 for the example database. A command-line translator requires manually copying and running each query. An agent-based workflow can instead inspect the schema, check a proposed query, and execute it through database tools. section 5.2.2 section 5.2.6 section 10.4.4
























