Query using SQL
Query one or more worksheets in a Google Sheets spreadsheet using SQLite syntax. Each worksheet is available as a SQL table using its worksheet name.
Only read-only SELECT queries are supported. Joins across worksheets are supported.
SQLite documentation: https://www.sqlite.org/docs.html
Common use cases
- Data Manipulation
- Filter, join, or reshape spreadsheet data before using it in later Wrk Actions
Application
- Google Sheets
Inputs (what you have)
| Name | Description | Data Type | Required? | Example |
|---|---|---|---|---|
| Google Sheets Connected Account | The Connected Account used to access the spreadsheet | Connected Account | Yes | |
| Spreadsheet link | Link to the Google Sheets spreadsheet. Example: https://docs.google.com/spreadsheets/d/SPREADSHEET_ID | URL | Yes | https://docs.google.com/spreadsheets/d/SPREADSHEET_ID |
| SQL query | A read-only SQLite SELECT query to run against the spreadsheet worksheets. Worksheet names are used as table names. Defaults to Select * from Sheet1 | Text (Long) | Yes | Select * from Sheet1 |
| Value format | How cell values should be returned from Google Sheets. Formatted values include display formatting such as currency and dates. Unformatted values return calculated raw values. Formulas return the formula text in formula cells | Predefined Choice List | No | Formatted values |
| Sheet configs | Optional per-worksheet overrides for header handling and start row. Provide one configuration object per worksheet | List of objects | No | See Sheet configs below |
Sheet configs
Use Sheet configs when a worksheet does not start on row 1, or when columns do not have headers. Add one configuration object per worksheet name.
| Name | Description | Data Type | Required? | Example |
|---|---|---|---|---|
| Sheet name | Worksheet name to configure. Sheet name is case sensitive | Text | Yes | Sheet1 |
| Columns do not have headers? | If selected, columns are referred to as Col1, Col2, etc. for this worksheet | True/False | No | false |
| Start row | First row to use when reading this worksheet. Use this to skip preamble rows above the header or data. Default 1 | Integer | No | 1 |
Note: The value of inputs can either be a set value in the configuration of the Wrk Action within the Wrkflow, or a variable from the Data Library. These variables in the Data Library are the outputs of previous Wrk Actions in the Wrkflow.
Outputs (what you get)
| Name | Description | Data Type | Required? | Example |
|---|---|---|---|---|
| Output JSON | JSON output of the query result | Text (Long) | No | |
| Total number of rows | The total number of rows returned by the SQL query | Integer | No |
Note: Custom Outputs can be configured to map columns from the query result into individual Data Library fields.
Outcomes
| Name | Description |
|---|---|
| Success | This status is selected if the query completed successfully and returned one or more rows. |
| No result | This status is selected if the query completed successfully but returned no rows. |
Requirements
- A Google Sheets Connected Account must be connected in Wrk.
- The spreadsheet must be accessible to the Google account used by the Connected Account.
How it works
- Every worksheet in the spreadsheet is loaded and exposed as a SQL table named after the worksheet title.
- Worksheet names that include spaces or special characters must be quoted in SQL. Example:
SELECT * FROM "Order Details". - By default, the first row of each worksheet is treated as column headers.
- Blank or duplicate header names are normalized for SQL use (blank headers become
Col1,Col2, etc.; duplicates get a numeric suffix). - Value format defaults to formatted values (
FORMATTED_VALUE). Choose unformatted values when you need raw calculated numbers instead of display strings such as$1.23. Choose formulas (FORMULA) when you need the formula text from formula cells. - Only read-only queries that start with
SELECTare allowed.WITH(CTE), insert, update, delete, and other write statements are not supported.
Example queries
Select all rows from a worksheet:
Select * from Sheet1
Filter rows:
Select Name, Country from Sheet1 where Country = 'Canada'
Join two worksheets:
Select Customers.Name, Orders.Total
from Customers
inner join Orders on Customers.CustomerId = Orders.CustomerId
Query a worksheet without headers (with Columns do not have headers? enabled in Sheet configs):
Select Col1, Col2 from Sheet1