🔤Text-to-SQL
Also known as Natural Language to SQL, NL2SQL, Text to SQL
Turning a question in plain words into SQL. Then a database can run it.
Think of it like
It is like asking a clerk how many red shirts you sold. He goes and checks the books.
Example
Emma asks how many orders came from Germany last month. The model writes the query. The database runs it and says 418.
Definition
Example code
sql
-- How many orders came from Germany last month?
SELECT COUNT(*) FROM orders
WHERE country = 'Germany'
AND order_date >= '2026-10-01'
AND order_date < '2026-11-01';Common mistake
Key takeaways
- 1Words to a query. A question becomes SQL.
- 2Needs the tables. The model must see the layout.
- 3Check the logic. Running is not the same as right.