View Categories

Natural Language to SQL: How Nova AI Turns Questions Into Database Queries

11 min read

AI POWERED

Nova AI Your Database

Nova AI Nova AI
Query Streams Query Streams
Your Database Your Database
Text to SQL
10 Dialects
Schema-Validated

Nova AI by Query Streams converts plain English questions into validated, dialect-specific SQL queries across ten database engines. You type “show me total sales by region for last quarter” and Nova generates the correct SQL with proper JOINs, aggregations, date functions, and dialect syntax for your specific database — PostgreSQL, MySQL, SQL Server, Oracle, Snowflake, BigQuery, or any supported engine. Every query passes through a four-stage validation pipeline before execution: schema discovery, column verification, join-path tracing, and syntax validation. This is what separates a production-ready text-to-SQL system from a general-purpose chatbot that guesses at table names. Below are five real examples showing how Nova translates increasingly complex natural language questions into accurate SQL. Try it free — no credit card required.

How Natural Language Becomes SQL
Five stages from your question to validated results
Your Question
“Top 10 products by revenue”
Schema Lookup
tables, columns, foreign keys
SQL Generation
dialect-specific query
Validation
syntax + schema check
Results
data grid or chart
1

Simple Filter: Plain English to WHERE Clause

The most common text-to-SQL pattern. Nova maps “from California” to the correct column and value.

Nova AI
Nova
PostgreSQL — crm_prod
Show me all active customers from California
User
Nova
“active customers”WHERE status = ‘active’
“from California”AND state = ‘CA’
Copy Run
SELECT company_name, contact_email,
       city, state, created_at
FROM public.customers
WHERE status = 'active'
  AND state = 'CA'
ORDER BY company_name
312 rows x 5 columns · 45ms
company_namecitystate
Alpine TechSan FranciscoCA
Bay AnalyticsOaklandCA
CloudBridge IncSan JoseCA
+ 309 more rows · Expand
Found 312 active customers in California. Nova detected that state uses 2-letter abbreviations (CA, not “California”) from column profiling. Want to filter by city or export this?
Ask Nova anything about your data…
2

Aggregation: “Total” and “By” Become SUM + GROUP BY

Nova recognizes aggregation intent from words like “total,” “average,” “count,” and grouping from “by category.”

Nova AI
Nova
MySQL — ecommerce
Total revenue by product category, sorted highest first
User
Nova
“total revenue”SUM(oi.quantity * oi.unit_price)
“by product category”GROUP BY p.category
“sorted highest first”ORDER BY total_revenue DESC
Copy Run
SELECT p.category,
       SUM(oi.quantity * oi.unit_price) AS total_revenue,
       COUNT(DISTINCT o.order_id) AS order_count
FROM products p
JOIN order_items oi ON p.product_id = oi.product_id
JOIN orders o ON oi.order_id = o.order_id
GROUP BY p.category
ORDER BY total_revenue DESC
8 rows x 3 columns · 92ms
categorytotal_revenueorder_count
Electronics$1,284,52012,840
Software$892,3408,920
Services$654,1003,270
+ 5 more categories · Expand
Electronics leads at $1.28M across 12,840 orders. Nova auto-joined 3 tables via product_id and order_id foreign keys. Want a bar chart or want to drill into a specific category?
Ask Nova anything about your data…
3

Date Ranges: “Last Quarter” to Dialect-Specific Date Functions

Natural date language maps to different SQL depending on your database engine. Nova handles this automatically.

Nova AI
Nova
SQL Server — finance_db
Monthly invoice totals for last quarter
User
Nova
SQL Server dialect detected — using DATEPART, DATEADD, TOP syntax
Copy Run
SELECT
  DATEPART(MONTH, invoice_date) AS invoice_month,
  DATENAME(MONTH, invoice_date) AS month_name,
  SUM(total_amount) AS monthly_total,
  COUNT(*) AS invoice_count
FROM dbo.invoices
WHERE invoice_date >= DATEADD(QUARTER, DATEDIFF(QUARTER, 0, GETDATE()) - 1, 0)
  AND invoice_date < DATEADD(QUARTER, DATEDIFF(QUARTER, 0, GETDATE()), 0)
GROUP BY DATEPART(MONTH, invoice_date),
         DATENAME(MONTH, invoice_date)
ORDER BY invoice_month
3 rows x 4 columns · 38ms
month_namemonthly_totalinvoice_countinvoice_month
January$148,3202341
February$162,8902512
March$157,4402483
February had the highest billing at $162,890. Note: because this is SQL Server, Nova used DATEPART and DATEADD instead of PostgreSQL’s date_trunc. The same question on Postgres would produce different but equivalent SQL.
Ask Nova anything about your data…
4

Complex Queries: Subqueries and Window Functions from One Sentence

Advanced questions generate multi-level SQL with CTEs, subqueries, or window functions — no SQL knowledge needed.

Nova AI
Nova
Snowflake — analytics_wh
Customers who spent more than the average this year, ranked by total spend
User
Nova
“more than the average”HAVING total_spend > (subquery)
“this year”WHERE YEAR(order_date) = 2026
“ranked by total spend”ORDER BY total_spend DESC
Copy Run Save
WITH customer_totals AS (
  SELECT c.customer_id, c.company_name,
         SUM(o.total_amount) AS total_spend
  FROM ANALYTICS.CUSTOMERS c
  JOIN ANALYTICS.ORDERS o ON c.customer_id = o.customer_id
  WHERE YEAR(o.order_date) = 2026
  GROUP BY c.customer_id, c.company_name
)
SELECT company_name, total_spend,
       RANK() OVER (ORDER BY total_spend DESC) AS spend_rank
FROM customer_totals
WHERE total_spend > (SELECT AVG(total_spend) FROM customer_totals)
ORDER BY total_spend DESC
47 rows x 3 columns · 210ms
company_nametotal_spendspend_rank
GlobalTech Solutions$428,9001
Meridian Corp$312,4502
Apex Manufacturing$289,1003
+ 44 more rows · Expand
47 customers exceed the average spend of $24,680. Nova used a CTE with a RANK() window function and a subquery filter. The Snowflake-specific uppercase schema references (ANALYTICS.CUSTOMERS) match your warehouse naming.
Ask Nova anything about your data…
5

Ambiguous Questions: Nova Asks Before Guessing

When your question could map to multiple tables or columns, Nova asks for clarification instead of hallucinating.

Nova AI
Nova
PostgreSQL — multi_tenant
Show me all the users
User
Nova
I found 3 tables that could match “users”:
1auth.users — 1,240 rows (login accounts with email, last_login, role)
2public.app_users — 8,920 rows (app profiles with name, plan, org_id)
3legacy.user_accounts — 450 rows (deprecated, migrated to auth.users)
Which table do you mean? Or should I join auth.users with app_users for the full picture?
Join auth.users with app_users
User
Nova
1,240 rows x 5 columns · 67ms
emailfull_nameplan
[email protected]James ChenEnterprise
[email protected]Sarah ParkPro
[email protected]Mike TorresPro
+ 1,237 more rows · Expand
Joined via auth.users.id = app_users.auth_user_id. All 1,240 accounts returned with login + profile data combined.
Ask Nova anything about your data…

What These Examples Show About Natural Language to SQL

Each demo above illustrates a different NL-to-SQL translation pattern that Nova handles automatically. Demo 1 shows the simplest case: mapping a filter phrase (“from California”) to a WHERE clause. What makes this non-trivial is that Nova detected the state column uses two-letter abbreviations, not full state names — a detail it learned from column profiling during schema discovery. A naive text-to-SQL system would generate WHERE state = 'California' and return zero results.

Demo 2 scales up to aggregation. Words like “total,” “average,” and “count” trigger SUM, AVG, and COUNT functions respectively. The phrase “by category” maps to GROUP BY, and “sorted highest first” maps to ORDER BY DESC. Nova also auto-detected that answering this question required joining three tables — products, order_items, and orders — which it did by tracing foreign key relationships in the schema. This is the kind of query that takes 30 seconds to describe in English but several minutes to write correctly in SQL, especially across unfamiliar table structures.

Demo 3 highlights dialect awareness. The phrase “last quarter” is a date concept that maps to completely different SQL depending on your database engine. On SQL Server, it becomes DATEADD(QUARTER, DATEDIFF(QUARTER, 0, GETDATE()) - 1, 0). On PostgreSQL, the same intent produces date_trunc('quarter', current_date - interval '3 months'). On Snowflake, it uses DATEADD('quarter', -1, DATE_TRUNC('quarter', CURRENT_DATE())). Nova generates the correct variant automatically based on your connected database type. This dialect-specific generation is what separates a production text-to-SQL tool from a general-purpose AI chatbot.

Demo 4 shows Nova handling an advanced analytical question that requires a CTE (Common Table Expression), a subquery for the average calculation, and a RANK() window function — all generated from a single English sentence. Demo 5 demonstrates what happens when your question is ambiguous: instead of guessing and potentially querying the wrong table, Nova presents the options and asks you to choose. This clarification step prevents the most common failure mode in AI-generated SQL — hallucinated table or column names that produce errors or incorrect results.

Why Validation Matters More Than Generation

Generating SQL from natural language is only half the problem. The harder half is making sure the generated SQL is actually correct for your specific database. General-purpose AI models like ChatGPT or Claude can write plausible-looking SQL, but they have no knowledge of your actual table names, column types, or relationships. They guess. And guesses fail silently — the query may run but return wrong results because it joined on the wrong column or filtered a column that uses different values than expected.

Nova solves this with a four-stage validation pipeline that runs before every query reaches your database. First, it discovers your real schema — every table, column, data type, and foreign key relationship. Second, it profiles column values to understand things like whether state uses “CA” or “California,” whether status uses 0/1 or “active”/”inactive,” and what the actual enum values are. Third, it traces join paths using real foreign keys rather than guessing at column name similarity. Fourth, it validates the final SQL through syntax parsing via sqlglot and column fuzzy matching with a 60% threshold using rapidfuzz. If a referenced column doesn’t exist or is misspelled, Nova catches it before execution and either corrects it automatically or asks you to clarify.

Supported Databases for Text-to-SQL

Nova’s natural language to SQL engine supports ten database platforms: PostgreSQL, MySQL, SQL Server (Microsoft), MariaDB, SQLite, Oracle, Snowflake, Google BigQuery, DuckDB, and Microsoft Access. It also supports six API connectors — Stripe, Shopify, HubSpot, Google Analytics 4, Google Search Console, and ShipStation — by syncing their data into local DuckDB tables that can be queried with standard SQL. Each database has its own SQL dialect with different syntax for dates, string functions, identifiers, pagination, and NULL handling. Nova generates the correct dialect automatically based on your connected data source, so you never need to think about LIMIT vs TOP, backtick quoting vs square bracket quoting, or NVL vs COALESCE. You can even switch between databases mid-conversation and Nova adjusts its SQL output accordingly.

Frequently Asked Questions

What is natural language to SQL?
Natural language to SQL (NL-to-SQL or text-to-SQL) is the process of converting plain English questions into structured SQL database queries. AI models parse the intent of your question, map it to your database schema, and generate the correct SQL syntax including SELECT, WHERE, JOIN, GROUP BY, and ORDER BY clauses. Nova takes this further by validating every query against your real schema before execution.
How accurate is AI-generated SQL?
Accuracy depends entirely on whether the AI has access to your real database schema. General-purpose chatbots like ChatGPT guess at table names and frequently hallucinate columns that don’t exist. Nova AI validates every query against your actual table names, column types, data values, and foreign key relationships through a 4-stage pipeline before the query ever reaches your database.
Can AI handle complex SQL with JOINs and subqueries?
Yes. Nova generates multi-table JOINs by tracing foreign key relationships in your schema, CTEs (Common Table Expressions) for analytical queries, window functions like RANK() and ROW_NUMBER(), and nested subqueries for comparative filtering. A single natural language sentence can produce a 15-line SQL query with multiple joins and aggregations.
Does the AI know my database structure?
Yes. Nova connects to your database through the Query Streams Agent, a lightweight service that runs on your own network. The Agent reads your real schema including every table name, column type, foreign key constraint, and data profile. Nova uses this metadata to generate accurate queries. Your actual data never leaves your network — only schema metadata is shared with the AI.
What databases support natural language queries?
Nova supports 10 databases: PostgreSQL, MySQL, SQL Server, MariaDB, SQLite, Oracle, Snowflake, BigQuery, DuckDB, and Microsoft Access. It also queries 6 API platforms (Stripe, Shopify, HubSpot, Google Analytics 4, Google Search Console, ShipStation) by syncing their data into local DuckDB tables. SQL dialect is automatically matched to each engine.
Can I edit the SQL that Nova generates?
Yes. Every generated query is shown with full syntax highlighting and interactive buttons for Copy, Run, Save, and Expand. You can modify the SQL before running it, re-run modified queries, or save them to your Query Library for repeated use in Microsoft Excel, Google Sheets, or the web portal. Saved queries become reusable assets your team can run without SQL knowledge.

Getting Started With Natural Language Database Queries

Setting up natural language to SQL with Nova takes under five minutes. Create a free account at my.querystreams.com, install the Query Streams Agent on any machine with database access, add your data source, and start asking questions. The Agent creates an encrypted outbound-only connection — no firewall changes, VPN tunnels, or inbound ports required. It runs on Windows, macOS, and Linux, self-updates automatically, and supports multiple simultaneous database connections.

AI credits are available through monthly subscriptions or one-time purchases. Nova is powered by advanced AI — Query Streams automatically selects the optimal provider for each query to deliver the best results. Any query Nova generates can be saved to your Query Library and shared with teammates who run it from the Microsoft Excel add-in or Google Sheets add-on — no SQL knowledge required on their end. Learn more about all Nova capabilities on the BI and AI Data Analytics feature page.

Meta Description: Natural language to SQL — type questions in plain English and get validated, dialect-specific SQL for PostgreSQL, MySQL, SQL Server, Snowflake, and 6 more databases. See 5 real examples.

Category: Nova AI
Tags: Natural Language to SQL, Text to SQL, AI SQL Generator, NL to SQL, AI Database Query, Nova AI, Query Streams, PostgreSQL, MySQL, SQL Server, Snowflake, BigQuery, AI Query Builder, Natural Language Database Query, Text to SQL Converter

Author Bio:
The Query Streams Team comprises seasoned database experts, network security professionals, and enterprise networking veterans with over 25 years of combined experience in data management, analytics, and secure software development.

Updated on June 3, 2026

Powered by BetterDocs