sql_query
Execute SQL SELECT queries on spreadsheet data to analyze, filter, and join information across sheets using a database-like interface.
Instructions
Execute a read-only SQL SELECT query against the spreadsheet data.
Every sheet in the workbook is loaded as a database table, with the header row defining column names and data rows below it. Returns results as a list of {column: value} objects.
Only SELECT (and WITH ... SELECT) statements are accepted. Use sql_execute for INSERT, UPDATE, or DELETE.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | Path to the spreadsheet file | |
| sql | Yes | SQL SELECT statement to execute. Each sheet is a table (quote names with double quotes if they contain spaces). Supports WHERE, ORDER BY, LIMIT, GROUP BY, HAVING, JOINs across sheets, DISTINCT, UNION, subqueries, and aggregates (COUNT, SUM, AVG, MIN, MAX). Example: SELECT name, revenue FROM Sales WHERE status = 'Active' ORDER BY revenue DESC LIMIT 20 | |
| header_row | No | 1-based row number containing column headers. Defaults to 1. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |