Overview
Use the WHERE clause to filter summary or timeseries rows before Horizon AI Query evaluates aggregations or grouping. When a GROUP BY clause is present, the filter runs first so only matching rows contribute to each group. The WHERE clause evaluates SQL-style predicates against the same column expressions that are available in theselect
and group_by
clauses.
Supported operators
WHERE predicates support these operators:- Comparison:
>
,>=
,<
,<=
,=
,!=
- Logical:
AND
,OR
,NOT
- Parentheses for explicit precedence
- String literals enclosed in single quotes (for example,
'long_sleep'
)
stage_rem_second
) or Source columns (for example, source_type
).
Column identifiers follow the Continuous Query column names. See Column Mappings for a full list.
Filter rows before grouping
Combine multiple device sources
Filter for specific provider and source type combinations with parentheses to manage precedence.Filter without grouping
You can apply a WHERE clause to ungrouped queries to trim the dataset before computing aggregates.where
property.
Evaluation order
- Apply the WHERE predicate to the incoming rows.
- Evaluate the GROUP BY clause (if provided) on the filtered rows.
- Calculate the aggregates in the SELECT clause.