Apama Documentation : Using Apama with Software AG Designer : Using Query Designer : Creating queries in Query Designer : Adding query aggregates : Adding query aggregate filters
Adding query aggregate filters
A query can specify a Boolean expression that uses an aggregate function that must evaluate to true for the query actions and any other procedural code are invoked. For an overview of all built-in aggregate functions, see Built-in aggregate functions.
When a query does not specify an aggregate calculation or filter, only the most recent set of events that match the pattern are used to invoke the actions and any other procedural code. With an aggregate calculation or filter, every set of events, in the current set of events, that matches the pattern is available for use by the aggregate function, provided that the latest event is present in one of the sets of events. Any events or combinations of events that do not match the pattern or do not meet specified query conditions, are ignored; their values are not used by the aggregate function.
To add an aggregate filter to a query
1. In the Query Designer Aggregates pane, click the down arrow next to the plus sign and select Filter (having).
2. In the New Query Aggregate Filter dialog, specify a Boolean expression that uses an aggregate function with identifiers from the pattern. You can also use parameters.
The first() and last() built-in aggregate functions process the oldest or newest event in the current set of events that the query is processing, respectively.
For example, this aggregate filter causes the query actions to be invoked only when the average price of trades is greater than 100.0:
avg(trade1.price) > 100.0
3. Click OK.
Query Designer displays the new aggregate filter in a row in the Aggregates pane.
To modify the aggregate filter, select it and then click the Edit icon.
To remove the filter, select it and then click the Delete icon .
Also, the new filter is immediately added to the source code as a having clause in the find statement. If you modify the filter in the Source tab this is reflected in the Aggregates pane in the Design tab.
You can add one or more aggregate calculations as well as one or more aggregate filters. The order in which they appear in the Aggregates pane is the order in which they are executed in the query. To change the order, select an aggregate and click the up arrow or down arrow as needed.
See also: Aggregating event field values.
Copyright © 2013-2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback