Developing Apama Applications > EPL Streams: A Quick Tour > Common stream query patterns > Joining the most recent event on each of two streams
Joining the most recent event on each of two streams
Another common pattern that has already been seen is that of comparing the most recent values from two event streams. The following code example illustrates this pattern with a use case example of calculating the price spread between two stocks.
01. event Price { string symbol; float price; }
02. monitor ComputeSpreads {
03. action onload() {
04. float spread;
05. from a in all Price(symbol="IBM") retain 1
06. from b in all Price(symbol="MSFT") retain 1
07. select a.price - b.price : spread {
08. print spread.toString();
09. }
10. }
11. }
Copyright © 2013-2015 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.