Skip to main content

Documentation Index

Fetch the complete documentation index at: https://sourcetable.com/docs/llms.txt

Use this file to discover all available pages before exploring further.

Sourcetable includes a built-in SQL editor that lets you query both spreadsheet data and connected databases using standard SQL syntax. It runs on DuckDB, which means fast, in-browser SQL execution.

Opening the SQL editor

Access the SQL editor from the sidebar or toolbar. You can also ask the AI: “Open the SQL editor.”

Querying spreadsheet data

Your sheet names act as table names, and column headers act as column names:
SELECT category, SUM(revenue) as total_revenue
FROM Sheet1
WHERE date >= '2024-01-01'
GROUP BY category
ORDER BY total_revenue DESC

Cross-sheet queries

Query across multiple sheets in the same workbook:
SELECT o.order_id, o.total, c.name, c.email
FROM Orders o
JOIN Customers c ON o.customer_id = c.id
WHERE o.total > 500
ORDER BY o.total DESC

Querying connected databases

When you have database connectors configured, select the data source from the dropdown at the top of the SQL editor, then write your query. Sourcetable runs the query on the remote database and returns results to your spreadsheet.
-- Querying a connected PostgreSQL database
SELECT product_name, SUM(quantity) as units_sold
FROM production.orders
JOIN production.products USING (product_id)
WHERE order_date >= CURRENT_DATE - INTERVAL '90 days'
GROUP BY product_name
ORDER BY units_sold DESC
LIMIT 20

Supported SQL features

FeatureSupportedExamples
SELECT / FROM / WHEREYesBasic queries with filtering
GROUP BY / HAVINGYesAggregations with conditions
ORDER BY / LIMITYesSorting and pagination
JOINYesINNER, LEFT, RIGHT, FULL, CROSS joins
SubqueriesYesNested SELECT statements
CTEsYesWITH clauses for readable queries
Window functionsYesROW_NUMBER(), RANK(), LAG(), LEAD(), SUM() OVER()
UNION / INTERSECT / EXCEPTYesCombining result sets
CASE expressionsYesConditional logic
Aggregate functionsYesSUM, AVG, COUNT, MIN, MAX, STDDEV, PERCENTILE_CONT
String functionsYesCONCAT, SUBSTRING, REPLACE, REGEXP_MATCHES
Date functionsYesDATE_TRUNC, DATE_DIFF, CURRENT_DATE
Type castingYesCAST(), ::type syntax

Visual query builder

The query builder lets you construct queries without writing SQL:
1

Select tables

Choose which sheets or connected tables to query from dropdown menus.
2

Pick columns

Select which columns to include in the output.
3

Add conditions

Build WHERE clauses with visual filter controls — select a column, operator (equals, contains, greater than, etc.), and value.
4

Configure joins

If querying multiple tables, define join conditions with visual dropdown selectors for left table, right table, and join columns.
5

Apply functions

Add aggregations, Excel-like functions (XL functions), and transformations.
6

Preview and run

See a live preview of your query results as you build. Click Run to execute.

Data library

Save frequently used queries for reuse:
  1. Write and test your query
  2. Click Save to Library
  3. Name and categorize the query
  4. Access it later from the data library in the sidebar
Saved queries can be shared with team members and reused across workbooks.

AI-powered queries

Instead of writing SQL manually, ask the AI in natural language:
  • “Show me the top 10 products by revenue this quarter”
  • “How many new customers signed up each month?”
  • “What’s the average order value by customer segment?”
The AI generates and runs the SQL query, then returns the results. See SQL generator for more details.