Natural Language SQL: Ask Your Data Questions in Plain English
Natural Language SQL: Ask Your Data Questions in Plain English
Most business questions get answered late — not because the data doesn't exist, but because the person with the question can't write SQL and the person who can write SQL is already backlogged three sprints deep. Natural language SQL is the attempt to close that gap, and in 2026 it's genuinely useful — with honest limits worth understanding before you rely on it.
What Is Natural Language SQL?
Natural language SQL (also called NL2SQL or text-to-SQL) is the process of converting a plain-English question into a SQL query that a database can execute. You type "What were our top 5 products by revenue last quarter?" and the system generates the SQL, runs it, and returns the result — no SQL knowledge required.
The underlying technology is a large language model that has been trained to understand database schemas and translate natural language intent into syntactically correct SQL. The model needs to know your schema — table names, column names, relationships — to generate useful queries. Without that context, it generates plausible-looking SQL that references tables that don't exist.
The terms text to sql, ai sql query, and nl2sql all describe the same core idea with slightly different emphases. NL2SQL is the research term; "text to SQL" is more common in commercial tooling; "natural language queries" is what ends up in marketing copy.
How It Works: Two Real Examples
Example 1: Revenue by Region
Plain English question:
"Show me total revenue by region for Q4 2024, sorted from highest to lowest."
AI-generated SQL:
-- Generated SQL (DuckDB dialect)
SELECT
region,
SUM(revenue) AS total_revenue
FROM orders
WHERE order_date >= '2024-10-01'
AND order_date < '2025-01-01'
GROUP BY region
ORDER BY total_revenue DESC;
Result:
| region | total_revenue |
|---|---|
| EMEA | 4,821,340 |
| North America | 4,203,890 |
| APAC | 2,109,450 |
| LATAM | 987,210 |
This is the straightforward case: a clean aggregation with a date filter and sort. The AI maps "Q4 2024" to the correct date range, understands "total revenue" means SUM(revenue), and applies the ORDER BY DESC the question implies. For queries like this — one table, clear intent, standard aggregation — NL2SQL is reliable.
Example 2: Month-over-Month Growth Rate
Plain English question:
"What's the month-over-month growth rate in new customer sign-ups for 2024?"
AI-generated SQL:
-- Generated SQL (DuckDB dialect) — uses window functions for MoM calculation
WITH monthly_signups AS (
SELECT
strftime(created_at, '%Y-%m') AS month,
COUNT(*) AS new_customers
FROM customers
WHERE created_at >= '2024-01-01'
AND created_at < '2025-01-01'
GROUP BY month
),
growth AS (
SELECT
month,
new_customers,
LAG(new_customers) OVER (ORDER BY month) AS prev_month,
ROUND(
100.0 * (new_customers - LAG(new_customers) OVER (ORDER BY month))
/ NULLIF(LAG(new_customers) OVER (ORDER BY month), 0),
1
) AS mom_growth_pct
FROM monthly_signups
)
SELECT month, new_customers, prev_month, mom_growth_pct
FROM growth
ORDER BY month;
Result:
| month | new_customers | prev_month | mom_growth_pct |
|---|---|---|---|
| 2024-01 | 1,240 | NULL | NULL |
| 2024-02 | 1,380 | 1,240 | +11.3% |
| 2024-03 | 1,520 | 1,380 | +10.1% |
| 2024-04 | 1,190 | 1,520 | -21.7% |
This is more complex — a window function with LAG(), a CTE, and a null-safe division. The AI gets it right because the pattern (MoM comparison) is common in training data. Notice the NULLIF(..., 0) to avoid division by zero — a detail a junior analyst might miss. When NL2SQL works at this level, it's genuinely useful.
NL2SQL Tools and Approaches: A Comparison
The NL2SQL landscape includes standalone tools, embedded features in BI platforms, and API-first approaches:
| Tool / Approach | How It Works | Best For | Accuracy on Complex Joins | Price |
|---|---|---|---|---|
| Harbinger Explorer | DuckDB WASM + AI agent chat; schema-aware generation | Browser-based data exploration, ad-hoc analysis | Good for single-table and simple joins | From €19/mo |
| ChatGPT / Claude (manual) | Paste schema + question into LLM chat | One-off queries when you have time to review | Variable — depends on schema clarity | Subscription or API cost |
| Defog / Wren AI | Open-source NL2SQL engines with schema metadata | Self-hosted data teams wanting full control | Good with proper metadata setup | Free (OSS) + cloud tiers |
| Databricks Genie | Natural language queries on Databricks Lakehouses | Enterprise teams already on Databricks | Strong (purpose-built for the platform) | Included in Databricks pricing |
| Tableau Pulse / Ask Data | NL2SQL within Tableau's semantic layer | Business users on existing Tableau dashboards | Limited to Tableau data sources | Included in Tableau licenses |
| Mode AI | NL queries on Mode datasets | Analysts on Mode platform | Moderate | Included in Mode plans |
Last verified: March 2026
The accuracy gap between "simple aggregation" and "multi-table join with business logic" is significant across all these tools. None of them are reliable for complex analytical queries without human review. The tools that work best in practice are the ones that combine NL2SQL with easy query inspection — so the user can see and verify the SQL before trusting the result.
When Natural Language SQL Fails
Honest inventory of where it breaks down:
Ambiguous column names. If your schema has a value column in six different tables, the model guesses which one you mean. It usually guesses wrong in surprising ways.
Complex multi-table joins with non-obvious keys. "Show me orders with their customer tier and the product category" requires knowing that orders.customer_id joins to customers.id, that customers.tier_id joins to tiers.id, and so on. Without explicit relationship metadata, the AI invents join conditions that look plausible but return wrong results.
Business logic that isn't in the schema. "Active customers" means different things at different companies — 30-day activity? Non-churned status? A flag? The model doesn't know your business definition. If it's not in the schema or a description field, the SQL will reflect a generic interpretation.
Time calculations that require domain context. "Last quarter" is usually fine. "Year-to-date adjusted for our fiscal year that starts April 1" requires business context the model doesn't have unless you explicitly provide it.
Queries that sound simple but require subqueries or statistical functions. "What's the median order value by customer segment?" sounds simple. The SQL requires a window function or a specialized median function — and the correct syntax varies by database. Model accuracy drops here.
Stale or incorrect schema context. If the model's schema context is outdated and a column was renamed last month, the generated SQL will fail. Schema freshness is a system design problem, not just a model problem.
Honest Trade-offs
| Dimension | What You Gain | What You Give Up |
|---|---|---|
| Speed for simple queries | Instant SQL without writing it | Reviewing the SQL to check it's correct |
| Accessibility | Business users can self-serve | Risk of wrong results being trusted without review |
| Iteration speed | Fast exploration and follow-up questions | Control over query structure and optimization |
| Complex joins | Attempt at the query | Accuracy — multi-table joins need human review |
| Discoverability | Natural entry point for unfamiliar schemas | You still need to know what questions to ask |
The most important trade-off: NL2SQL reduces the barrier to generating a query, not the barrier to trusting it. The critical skill shifts from "can I write this SQL?" to "can I tell if this SQL is correct?" — which is actually harder for non-technical users, not easier.
The tools that handle this well add query transparency: show the user the generated SQL, explain what it does, and make it easy to modify or rerun. The tools that hide the SQL behind a clean UI create a false sense of reliability.
Where It Genuinely Works Well
Despite the limitations, NL2SQL is genuinely useful in specific contexts:
- Exploratory analysis on familiar data — when a business analyst knows their own data model and just needs SQL generated for standard aggregations, NL2SQL saves significant time
- Getting unstuck on syntax — "how do I write a PIVOT in DuckDB?" is a legitimate use of an AI chat interface even if you verify the output
- First-pass analysis — generating a SQL draft that an analyst then edits and validates is often faster than writing from scratch
- Democratizing access to structured data — for truly simple questions against clean schemas, non-technical users can get real answers without waiting for an analyst
Harbinger Explorer takes this approach: a built-in AI agent chat interface that generates DuckDB SQL from natural language questions, shows you the query it built, and lets you run it against your connected data sources directly in the browser. The transparency — seeing and being able to modify the generated SQL — is what makes it trustworthy for real analysis rather than a novelty. You can try it on your own data with a 7-day free trial.
Getting the Best Results from NL2SQL
A few practical tips that consistently improve output quality:
-
Be specific about aggregation. "Show me revenue" is ambiguous. "Show me total revenue (sum of the
revenuecolumn in theorderstable) grouped by month" gives the model what it needs. -
Name your tables in the question. "How many rows are in
transactionswherestatus = 'completed'?" is more reliable than "How many completed transactions do we have?" -
Check the SQL before trusting the number. Especially for anything going into a report or decision. This should be a habit, not an exception.
-
Iterate conversationally. "That's close, but filter to only include paid plans" usually works better than trying to write the complete question in one shot.
Next Steps
Natural language SQL lowers the barrier to data exploration — with the caveat that result accuracy requires human verification for anything complex. To go deeper:
- For the underlying query engine that powers browser-based NL2SQL, see DuckDB Tutorial: Analytical SQL in Your Browser
- For organizing the data sources you want to query with natural language, see What Is a Data Catalog?
The field is moving fast. Models are improving at multi-table joins and business logic inference. But the fundamental constraint — "the model doesn't know your business definitions" — is a data governance problem, not just a model problem. The best NL2SQL implementations pair the AI with well-documented schemas and clear business metadata.
Continue Reading
- DuckDB Tutorial: Analytical SQL Directly in Your Browser
- What Is a Data Catalog? Tools, Trade-offs and When You Need One
- Self-Service Analytics: A Practical Guide for Data Teams
[VERIFY] Databricks Genie feature availability — confirm GA status vs. beta as of March 2026
[VERIFY] Defog / Wren AI current feature set and open-source status
[PRICING-CHECK] All tool pricing tiers — last verified March 2026
Continue Reading
DuckDB Tutorial: Analytical SQL Directly in Your Browser
Get started with DuckDB in 15 minutes. Learn read_parquet, read_csv_auto, PIVOT, and when DuckDB beats SQLite and PostgreSQL for analytical SQL.
Building a REST API Data Pipeline in Python
A step-by-step guide to building a production-grade REST API data pipeline in Python. Covers authentication, pagination, rate limits, schema validation, and common pitfalls with real runnable code.
Excel to SQL: A Migration Guide for Business Analysts
Complete guide to Excel to SQL migration for business analysts. 25-row concept mapping table, SQL code examples, common pitfalls, and tips for making the switch stick.
Try Harbinger Explorer for free
Connect any API, upload files, and explore with AI — all in your browser. No credit card required.
Start Free Trial