-- Create an unnamed window to track average price by stock symbol
INSERT INTO FilteredTrades
SELECT *, AVG(Price)
FROM StockTrades
KEEP 3 ROWS
WHERE Symbol = 'EBAY' OR Symbol = 'IBM'
GROUP BY Symbol;
This single statement produces the same results as the three statements introduced in Aggregating Values. In this case, the KEEP clause by itself creates an implicit or unnamed window (as opposed to the named window you defined before). When you use the GROUP BY clause with an unnamed window, it groups the aggregate calculations and also groups the contents of the window, just like the PER clause. In this case, the window behaves as if you had specified "KEEP 3 ROWS PER Symbol".