The statistics are created from a query on the input table finance_data3 and grouped by column id.
SELECT * FROM SAX2 ( ON finance_data3 AS INPUT PARTITION BY id ORDER BY id ON (SELECT id, AVG (expenditure) AS expenditure, AVG (income) AS income, AVG (investment) AS investment FROM finance_data3 GROUP BY id) AS meanstats PARTITION BY id ON (SELECT id, STDDEV (expenditure) AS expenditure, STDDEV (income) AS income, STDDEV (investment) AS investment FROM finance_data3 GROUP BY id) AS stdevstats PARTITION BY id ValueColumns ('expenditure', 'income', 'investment') TimeColumn ('period') WindowType ('global') PrintCodeStats ('true') Accumulate ('id') ) ORDER BY id;