Skip to main content

Query table in Datastore

Query Datastore using SQL. Wrk Action uses SQLite syntax. Note: To retrieve the row ID, include the _id field in your SELECT clause.

Application

  • Datastore

Inputs (what you have)

NameDescriptionData TypeRequired?Example
SQL querySQL Statement to fetch data from Datastore. Note: To retrieve the row ID, include the _id field in your SELECT clause.Text (Long)YesSELECT * FROM DataTable1

Outputs (what you get)

NameDescriptionData TypeRequired?Example
Total number of rowsThe total number of rows in the output JSONNumberNo
Output JSONJSON output of the query resultText (Long)No

Outcomes

NameDescription
SuccessThis status is selected if the job has successfully completed.

SQL Configuration Instructions

Wrk supports a subset of SQLite-style SQL queries for retrieving, filtering, and aggregating data.

This allows you to perform common data operations such as selecting fields, applying filters, grouping, and sorting results — all using familiar SQL syntax.

The supported syntax covers most analytical and filtering scenarios but excludes advanced database operations (like subqueries or window functions).


Supported Clauses

SELECT Clause

Syntax

SELECT field1, field2, ... SELECT field AS alias SELECT SUM(field), COUNT(*), AVG(field), MIN(field), MAX(field) SELECT * FROM table

Meaning

Use SELECT to define which fields to return.

Aggregate functions like SUM, AVG, MIN, MAX, and COUNT are supported.

Aliasing (AS alias) can rename fields in the output.

FunctionDescription
SUM(x)Adds up all values of x
AVG(x)Returns the average of x
MIN(x)Returns the smallest value of x
MAX(x)Returns the largest value of x
COUNT(*)Counts total rows

Examples

Basic Selection

SELECT name, age FROM users

Aggregation

SELECT department, COUNT(*) AS total FROM employees GROUP BY department

FROM Clause

Syntax

FROM table FROM table AS alias

Defines the dataset to query.

Table aliases are supported and can be used to simplify references in joins or where conditions.

Example

SELECT u.name FROM users AS u

WHERE Clause

Syntax

WHERE field = value WHERE field > 10 WHERE field BETWEEN 10 AND 20 WHERE name LIKE '%john%' WHERE date >= '2024-01-01' WHERE status IN ('active', 'pending') WHERE amount NOT IN (0, NULL) WHERE field IS NULL WHERE field IS NOT NULL

Supported Operators

OperatorDescription
= / ==Equal to
!= / <>Not equal to
> / <Greater / Less than
>= / <=Greater or equal / Less or equal
IN (...)Value exists in a list
NOT IN (...)Value does not exist in a list
LIKEPattern match (% for any string, _ for a single character)
IS NULLField is missing or null
IS NOT NULLField is present and not null
AND, ORCombine multiple conditions

Examples

Numeric Comparison

SELECT * FROM orders WHERE total > 100

Pattern Matching

SELECT * FROM users WHERE email LIKE '%@example.com'

Combined Conditions

SELECT * FROM users WHERE active = true AND age >= 18

Null Check

SELECT * FROM logs WHERE deleted_at IS NULL

JOIN Clause

Syntax

SELECT * FROM users JOIN orders ON users.id = orders.user_id

Supports simple equality joins between tables using JOIN ... ON.

Each join is equivalent to a relational lookup between matching fields.

Example

SELECT u.name, o.total FROM users AS u JOIN orders AS o ON u.id = o.user_id

GROUP BY Clause

Syntax

GROUP BY field1, field2

Used with aggregation functions to summarize data into groups.

Example

SELECT department, AVG(salary) AS avg_salary FROM employees GROUP BY department

ORDER BY Clause

Syntax

ORDER BY field ASC ORDER BY field DESC

Sorts results in ascending (ASC) or descending (DESC) order.

Multiple sort fields are supported.

Example

SELECT name, created_at FROM users ORDER BY created_at DESC

LIMIT and OFFSET Clauses

Syntax

LIMIT n OFFSET n

Use LIMIT to restrict the number of rows returned, and OFFSET to skip a certain number of rows before returning results.

Example

SELECT name, email FROM users LIMIT 10 OFFSET 20

Data Type Handling

When filtering or comparing values, Wrk automatically converts SQL literals into appropriate types.

Example InputInterpreted As
'text'String
"text"String
123Integer
3.14Float
true / falseBoolean
'2025-01-01T00:00:00Z'DateTime
NULLNull value

Date strings must follow ISO 8601 format (YYYY-MM-DD or YYYY-MM-DDTHH:MM:SSZ).


Supported Features Summary

FeatureSupportedExample
SELECTSELECT field1, field2
Aggregate FunctionsSELECT COUNT(*) FROM ...
WHEREWHERE field = 5
LIKEWHERE name LIKE '%test%'
IN / NOT INWHERE field IN ('A', 'B')
IS NULL / IS NOT NULLWHERE field IS NOT NULL
AND / ORWHERE a = 1 AND b = 2
GROUP BYGROUP BY department
ORDER BYORDER BY date DESC
LIMIT / OFFSETLIMIT 10 OFFSET 5
JOINJOIN orders ON users.id = orders.user_id
SubqueriesNot supported
UNION / INTERSECTNot supported
HAVINGNot supported
Window FunctionsNot supported

Example Queries

Example 1: Filter and Sort

SELECT name, age FROM users WHERE age >= 18 ORDER BY name ASC LIMIT 5

Example 2: Aggregation with Grouping

SELECT department, COUNT(*) AS total FROM employees WHERE active = true GROUP BY department ORDER BY total DESC

Example 3: Join Between Tables

SELECT u.name, COUNT(o.id) AS total_orders FROM users AS u JOIN orders AS o ON u.id = o.user_id GROUP BY u.name ORDER BY total_orders DESC

Notes

  • Queries must follow standard SQLite formatting.
  • Unsupported syntax will return an error.
  • Quotation marks (' or ") around string literals are interchangeable.
  • Date comparisons and pattern matching (LIKE) are case-insensitive by default.