Bound data continuously by time
The following variation on ProductData_15MIN
summarizes events continuously:
CREATE WINDOW ProductData_15MIN OVER RetailOrders KEEP WITHIN 15 MINUTE ON dateTime; CREATE CQ GetProductActivity INSERT INTO ProductTrackingStream SELECT pd.sku, COUNT(*), SUM(pd.orderAmount) FROM ProductData_15MIN pd;
Omitting JUMPING
from the window definition creates a sliding window (see Window in the Concepts Guide). Every time a new order is received, or one is dropped because it has been in the window for 15 minutes, the output stream receives a new event updating the number of orders and total amount of those orders for the past 15 minutes. FIRST(pd.dateTime)
is unnecessary since you know the window always contains the most recent orders.