Alternate Intervals for Jumping Time-Based Windows

Describes how to offset the beginning of the interval for a time-based window to another time than the default.

By default, a jumping time-based window begins its intervals offset from January 1, 1970 at midnight. In the previous example, this means that the window intervals always begin and end at 0:00, 0:10, 0:20, and so on. If you want to offset the beginning of the interval for your window from the default (for instance, so that the intervals can begin and end at 0:05, 0:15, and so on), add the STARTING AT subclause to the window definition, using the following syntax:

KEEP EVERY interval-literal STARTING AT interval-literal

Here is the previous example again, shown with the additional STARTING AT subclause, which causes the window intervals to be offset by 5 seconds:

INSERT INTO StockTradesMicrosoft 
SELECT volume, price 
FROM StockTrades 
WHERE symbol = 'MSFT'; 

INSERT INTO AvgPriceMicrosoft 
SELECT AVG(price) 
FROM StockTradesMicrosoft 
KEEP EVERY 10 seconds 
STARTING AT 5 seconds;


Created March 8, 2010. Send feedback on this help topic to Sybase Technical Publications: pubs@sybase.com