AI SQL query generator
GPTExcel's SQL generator writes a SQL query from a plain-English description, in the dialect of the database you choose, from PostgreSQL and MySQL to SQL Server, Oracle, BigQuery, and Snowflake. It can also explain a query or suggest a faster rewrite.
How it works
From plain English to a working query
- 1
Choose your database dialect
Pick the database the query will run on, such as PostgreSQL, MySQL, MSSQL Server, Oracle DB, or Snowflake, so functions and syntax match it.
- 2
Describe the query
Say what you want back in plain English. Include your table and column names for the most accurate result.
- 3
Generate
GPTExcel returns the query in a copyable code block with a short explanation of the joins, filters, and grouping it uses.
- 4
Explain or optimize
Paste an existing query into Explain mode to understand it, or into Optimize mode for a tuned rewrite and index suggestions.
Example
One prompt, one result
A typical request and the kind of answer the SQL tool returns. AI output varies, so check it against your own data before you rely on it.
Top 5 customers by total revenue this year. Tables: customers(id, name), orders(id, customer_id, total, created_at)
Result
Here's a PostgreSQL query that ranks customers by this year's order revenue and keeps the top five.
SELECT c.id, c.name, SUM(o.total) AS total_revenue
FROM customers c
JOIN orders o ON o.customer_id = c.id
WHERE o.created_at >= date_trunc('year', CURRENT_DATE)
GROUP BY c.id, c.name
ORDER BY total_revenue DESC
LIMIT 5;date_trunc('year', CURRENT_DATE)is January 1 of the current year- Grouping by
c.idkeeps customers with the same name separate - An index on
orders (created_at, customer_id)helps on large tables
Supported dialects
Written for the tool you actually use
Every mode works with every option below: Generate, Explain, Optimize.
SQL
SQLite
MySQL
MariaDB
PostgreSQL
Oracle DB
MSSQL Server
Microsoft Access
Amazon Aurora
Google Cloud SQL
BigQuery
CockroachDB
Apache Derby
IBM Db2
SAP HANA
Teradata
Informix
Sybase
Firebird
Snowflake
HyperSQL Database
MonetDB
Frequently asked questions
- Which databases does the SQL generator support?
- Standard SQL, SQLite, MySQL, MariaDB, PostgreSQL, Oracle DB, MSSQL Server, Microsoft Access, Amazon Aurora, Google Cloud SQL, BigQuery, CockroachDB, Apache Derby, IBM Db2, SAP HANA, Teradata, Informix, Sybase, Firebird, Snowflake, HyperSQL Database, and MonetDB.
- Does it connect to my database?
- No. It writes the query text from your description; you run it in your own database client. Including your table and column names in the prompt gives the most accurate query.
- Can it explain or speed up a query I already have?
- Yes. Explain mode gives a readable walkthrough of the joins, filters, and grouping, and Optimize mode returns a tuned rewrite with suggested indexes.
- Is the SQL generator free?
- Yes, you can start free. The free plan includes 4 tool runs every 12 hours, shared across the Formula, Script, SQL, Regex, and Template tools, and paid plans raise that limit. You need a free GPTExcel account to use it.
Try the SQL tool free
No credit card required. The free plan includes 4 tool runs every 12 hours.
Sign in and start generating