Text to SQL

Let AI answer from your company’s data.

To answer questions about revenue, inventory or customers, AI needs access to your enterprise database. NL to SQL lets AI turn a question into SQL and answer using the data returned.

The data the question needs

What is NL to SQL

Let AI query enterprise data and answer with the results.

For a question such as “What was net revenue by region last month?”, the AI uses business terminology and schema context to generate SQL. The system checks that SQL and the user's permissions, runs it read-only against the enterprise database, and hands the results back to the AI, which writes the answer.

Sources: Gao et al. (2024) · AWS × Cisco

  1. Business questionPeriod, subject, metric
  2. AI composes SQLSchema and definitions
  3. Database queryPermissions and validation
  4. AI answersResult, conditions, sources

Why it matters

Answers grounded in current data

Query the database when a question arrives, bringing business records into the AI answer.

Aggregation stays in the database

Use SQL for filters, totals and joins across periods, departments and products.

Build on the existing data structure

Keep the tables, views and SQL infrastructure you already run, and add natural-language querying on top.

The value of a dedicated workflow

What changes when AI gains a dedicated NL to SQL workflow?

This published study compares giving the AI the full schema against adding relevant-data retrieval, schema selection and SQL revision. It shows how much the information the AI receives, and the steps around it, change query accuracy.

CHESS research · 147 BIRD development questions · SQL generation: GPT-4-turbo · No fine-tuning

Compare SQL execution accuracy for a GPT-4-turbo baseline and a dedicated NL to SQL workflow. Execution accuracy rose from 46.25% to 55.78%, a gain of 9.53 percentage points. Relevant context and query revision improved the resulting database queries.

Execution accuracy rose from 46.25% to 55.78%, a gain of 9.53 percentage points. Relevant context and query revision improved the resulting database queries.

Execution accuracy (EX) measures whether generated SQL returns the reference result.

View the comparison data
Compare SQL execution accuracy for a GPT-4-turbo baseline and a dedicated NL to SQL workflow.
ConfigurationExecution accuracy
GPT-4-turbo: question, evidence, full schema + CoT46.25%
CHESS: retrieval, schema selection, SQL revision (no fine-tuning)55.78%

Talaei et al. · CHESS v1 (2024) · Tables 2, 4

Baseline: question, evidence, full schema and CoT. The workflow adds retrieval, selection and revision, with GPT-3.5-turbo for column filtering.

Published CHESS v1 results from Talaei et al.; not QueryMind measurements or a promised improvement rate.

How QueryMind applies this principle

QueryMind gives the AI the business terminology and data structure, validates the SQL it generates, checks permissions and runs the query read-only against the enterprise database. The AI then answers from the company's own definitions and the data returned.

Research behind the technology

An enterprise design pattern that first identifies the relevant data domain, then supplies its schemas, descriptions and business rules.

AWS × Cisco

Research and application at BLUEURBAN

QueryMind: query company data and answer from the results.

BLUEURBAN studies how AI can understand company terminology and query data within the user’s permissions. QueryMind turns questions into SQL queries. QueryMind Connect makes validated business-metric queries available as tools for other AI clients.

Illustrative example

A revenue question needs your company’s definition of revenue.

Business question

What was net revenue by product last month?

AI

  • Identify the period and metric in the question.
  • Compose SQL using the relevant tables and relationships.

QueryMind

  • Example definition: net revenue = sales − returns
  • Check permissions and SQL, then query in read-only mode.

An answer grounded in data

  • Net revenue by product
  • Period and calculation rules
  • Source data and executed query
Give AI the company’s definitions
Give the AI business terms, metric and period definitions alongside the schema so its SQL follows company definitions.
Check the answer against the query result
Show the query result, after SQL validation, authorization and read-only execution, alongside the answer it supports.
Use the same query tools across AI clients
Publish approved query definitions as MCP tools for reuse in connected AI clients.
BLUEURBAN engineering blog
Applied at BLUEURBANQueryMindQuery workspaceQueryMind ConnectMCP publishingClaudeMCP connectorChatGPTMCP connector

Frequently asked questions

Q1

Why use NL to SQL to connect AI to an enterprise database?

It translates a business request into SQL the database can execute. The AI interprets the question, the existing database does the querying and aggregation, and the answer rests on actual business data.

Q2

How can it work with document-retrieval RAG?

Document retrieval can supply policies and explanations, while SQL handles structured-data questions such as revenue totals or inventory levels. Retrieved schema descriptions and business rules can also inform SQL generation.

Q3

Does a different model automatically improve results?

Schema representation, business terminology, selected examples, question difficulty and review all influence results. An applied evaluation should compare accuracy, latency and cost using the same questions and data conditions.

Q4

How can it work with BI and dashboards?

A dashboard can serve recurring metrics while natural-language queries explore new conditions and follow-up questions. Reviewed queries can then become reusable definitions.

Q5

How does this connect to QueryMind?

QueryMind uses it to turn business questions into SQL, validate and run them against the enterprise database, and show the result alongside the SQL. QueryMind Connect publishes those reviewed queries as MCP tools for other AI clients.

Papers and resources

  1. Text-to-SQL Empowered by Large Language Models: A Benchmark Evaluation

    PVLDB · 2024 / arXiv v4 · 2023

  2. Spider 2.0: Evaluating Language Models on Real-World Enterprise Text-to-SQL Workflows

    ICLR · 2025

  3. Enterprise-grade natural language to SQL generation using LLMs: Balancing accuracy, latency, and scale

    AWS Machine Learning Blog · 2025-04-24

  4. CHESS: Contextual Harnessing for Efficient SQL Synthesis

    arXiv v1 · 2024-05-27

Help AI answer from your business data.

Review the query scope using your business definitions and database structure.

Discuss data access