Back to guide

SQL Query Engine

Write SQL queries against your loaded spreadsheet data to filter, group, aggregate, and reshape rows — all in the browser with no database required.

Overview

SheetTool includes a built-in SQL engine that treats your loaded data as a table named 'data'. You can write standard SQL queries with SELECT, WHERE, GROUP BY, ORDER BY, DISTINCT, and TOP N. Aggregate functions like SUM, COUNT, AVG, MIN, and MAX are supported. Query results can be pushed back into the spreadsheet as your new working dataset, making SQL a powerful way to reshape data before export.

Syntax & Reference

SELECT columns FROM data
Select specific columns by name, or use SELECT * to return all columns. Column names with spaces need to be quoted.
WHERE condition
Filter rows using conditions with =, !=, >, <, >=, <=, LIKE, and IN operators. Combine conditions with AND/OR.
GROUP BY column
Group rows by one or more columns and apply aggregate functions to summarize each group.
ORDER BY column ASC|DESC
Sort results by one or more columns in ascending or descending order.
SUM, COUNT, AVG, MIN, MAX — Aggregates
Calculate totals, counts, averages, minimums, and maximums. Use with GROUP BY for per-group summaries.
DISTINCT, TOP N
DISTINCT removes duplicate rows from results. TOP N limits output to the first N rows after sorting.
Push results to spreadsheet
After running a query, push the results back into the grid to replace or supplement the current sheet data.

Examples

Filter active customers with missing emails

SELECT * FROM data WHERE status = 'active' AND (email IS NULL OR email = '') — creates a cleanup queue you can export and work through.

Group orders by region and month

SELECT region, month, SUM(total) as revenue, COUNT(*) as orders FROM data GROUP BY region, month ORDER BY revenue DESC — a quick summary report without pivot tables.

Extract specific columns for export

SELECT sku, name, price, inventory FROM data WHERE inventory > 0 — create a trimmed export with only the columns another system accepts.

Find duplicates

SELECT email, COUNT(*) as cnt FROM data GROUP BY email HAVING cnt > 1 — identify duplicate entries by any column.

Tips & Best Practices

  • Start with SELECT * FROM data to confirm column names, then narrow the query to specific columns and conditions.
  • Push query results back into the sheet when the output becomes your new working dataset — this saves re-running the query.
  • Use built-in query templates to get started quickly, then customize the WHERE clause and column list.
  • Combine SQL with other SheetTool features: query to filter, then use transforms or formulas on the result set.

Frequently Asked Questions

What SQL dialect does SheetTool support?+

SheetTool uses a SQLite-compatible SQL engine that runs in the browser. It supports standard SELECT queries with WHERE, GROUP BY, ORDER BY, HAVING, DISTINCT, and common aggregate functions. It does not support INSERT, UPDATE, DELETE, or DDL statements since the data comes from your spreadsheet.

Can I join multiple tables?+

Currently, SQL queries operate on a single table named 'data' which represents your loaded spreadsheet. To work with multiple files, use the merge feature to combine them first, then query the merged result.

Is my data sent to a server for SQL processing?+

No. The SQL engine runs entirely in your browser using WebAssembly. Your data never leaves your device.

Can I save and reuse SQL queries?+

SheetTool provides built-in query templates for common operations. You can also copy your query text and paste it back later. For repeatable workflows, consider recording a macro that includes the SQL step.