Sometimes it is the case that results are only required at a given rate. We can extend the example in
Aggregation in stream queries by adding an
every clause, so that the query generates values only every 10 seconds.
01. using com.apama.aggregates.wavg;
02. event Tick { string symbol; float price; float volume; }
03. monitor CalculateVwap {
04. action onload() {
05. float vwap;
06. from t in all Tick(symbol="SOW") within 300.0 every 10.0
07. select wavg(t.price,t.volume): vwap {
08. print vwap.toString();
09. }
10. }
11. }