Built-in Functions → query

query() is a query function that queries a column and returns values that satisfy one or more optional filter conditions.

Context

You can use query functions when creating the query expressions of global variables, internal session variables, and In-Query filters.

For more examples and details about referenceable objects and variables, refer to Concepts → Internal Query Expression.

Note

The maximum number of values this function can return is 1000. To have more values returned, use the queryWithLimit() function.

Signature

query(column, filter1, filter2, ...)
ParameterDescription
columnRequired.
The fully qualified name of the column to query its values
filterOptional.
The conditions to be evaluated against each column value to decide on the values to return. A value must satisfy all filter conditions to be considered in the function output.

Returns

A single value or an array of values.

The data type of the returned values depends on the column data type and the function’s usage context. When the function is used in a global variable the type of the returned values is the same as the column’s data type. In the case of a session variable or an In-Query filter, the type of the returned value is always string.

Example

Query the AMOUNT_SOLD column and return the values where the CALENDAR_YEAR is 2003.

query(SALES.SALES.AMOUNT_SOLD, SALES.SALES.CALENDAR_YEAR =2003)