JSON Functions And Operators

Estimated reading time: 6 min
All functions available in Wiresk can be used with any subscription plan without any usage limitations.

JSON functions are built-in functions provided by a database to perform operations on JSON data. These functions allow you to:

  • Create JSON objects or arrays.
  • Extract specific values from JSON documents.
  • Modify JSON data (insert, update, or remove key-value pairs).
  • Validate JSON data.
  • Aggregate data into JSON structures.

JSON operators are symbols or keywords used to interact with JSON data in SQL queries. They are often used to:

  • Access specific elements in a JSON document.
  • Check if a key or value exists in a JSON document.
  • Compare JSON values.

These functions and operators are categorized into scalar functions and aggregate functions.

Refer to Core Functions documentation to see how to use Functions in Wiresk
 
For more details, see official SQLite JSON Functions And Operators

Scalar functions operate on individual JSON values and return a single value. These functions are used for creating, querying, and modifying JSON data.


Aggregate functions in SQLite perform calculations on multiple rows of data and return a single result.

Computes the average (mean) value of X across all selected rows.

Example: Average Product Price

avg(price)

Output:

250.50
  • If the products table contains {100, 200, 300, 400}, the average would be 250.50.
  • NULL values are ignored in the calculation.

Counts the number of non-NULL values in column X.

Example: Count Active Users

count(id)

Output:

25
  • Counts all id values where status='active'.
  • If count(*) is used, it counts all rows, including those with NULL values.

Returns a comma-separated list (or custom separator Y) of values in column X.

Example: List of Active Users

group_concat(username, ', ')

Output:

Alice, Bob, Charlie
  • All active users’ username values are concatenated into a string.

Returns the highest value in column X.

Example: Highest Order Total

max(total)

Output:

5000
  • Finds the highest order total in the orders table.

Returns the lowest value in column X.

Example: Lowest Product Price

min(price)

Output:

25.99
  • Finds the cheapest product price in the products table.

Computes the sum of all values in column X.

Example: Total Revenue

sum(total)

Output:

125000
  • Sums the total column for completed orders.
  • NULL values are ignored.

Similar to sum(X), but treats NULL values as 0 instead of ignoring them.

Example: Total Sales, Including NULLs

total(sales)

Output:

120000
  • Unlike sum(X), if all rows are NULL, total(X) returns 0 instead of NULL.

See more about functions in Wiresk. 
Explore our User Guide
For a complete tutorial on how to create a Flow, see “How to create a Flow in Wiresk”